Don't be fulled by Identifiable
I was working on a Caffeine++ update and needed to upgrade the internal database. I happened to catch a bug, luckily before the release, where some of my drinks wouldn’t migrate correctly.
We know that to find a match, we can explicitly point to the id property:
.first(where: { $0.id == object.id })
And we also can write this, which complies. And you would think it does the same thing because object on the left and right conform to Identifiable
.
.first(where: { $0 == object })
But in my case, only the first, longer option works correctly. Oddly, the shorter version fails only sometimes. I am not sure why.