Skip to content
Discussion options

You must be logged in to vote

Hi @StewartLynch, this is an example where Swift's optional promotion cannot work, and so you are forced to deal with how to compare an optional and non-optional thing. And further, SQL has a 3-valued logic system (true, false, NULL), and in that system nothing is equal to NULL, even NULL itself. That can make things confusing, but what it means in practice is that when comparing things that can be NULL, you should use the "IS" operator instead of "=":

The IS and IS NOT operators work like = and != except when one or both of the operands are NULL. In this case, if both operands are NULL, then the IS operator evaluates to 1 (true) and the IS NOT operator evaluates to 0 (false). If one ope…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mbrandonw
Comment options

Answer selected by StewartLynch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants