Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Likes the False value better?

Im reading Jon Skeet book. (#4)

but one thing (among others) caught my eye :

topic : bool?

he wrote in a table that :(X,Y are bool?)

X      |    Y     |   X & Y
---------------------------
true        null       null

ok fine... so the null is the one who decides. the bool operand here looses.

X      |    Y     |   X & Y
---------------------------
false      null       false

why ? why the bool operand here is being taking into account while in the previous sample it was the null who decided about the result ...?

It seems that true and false has friends in different places....:)

like image 538
Royi Namir Avatar asked Dec 07 '22 16:12

Royi Namir


1 Answers

Pronounce null as unknown.

true  & unknown => unknown
false & unknown => false       because the second operand does not matter. 

And of course there is the mirror table for OR :

true  | unknown => true        because the second operand does not matter. 
false | unknown => unknown       

And it holds for && and || as well.

like image 154
Henk Holterman Avatar answered Dec 26 '22 11:12

Henk Holterman