So I ran into a situation today where some production code was failing precisely because a method performed exactly as documented in MSDN. Shame on me for not reading the d
You will find this behaviour quite often in other areas of mathematics or computer science.
The SUM operator in Math will return 0 (the neutral element of +) in cases where the ranges are invalid (the SUM from 0 up to -1). The MULTIPYL operator will return 1 (neutral element for multiplication).
Now if you have Boolean expressions, it's quite similar: The neutral element for OR is false
(a OR false = a
) whereas the neutral element for AND is true
.
Now on Linq's ANY
and ALL
: They are similar to this:
ANY = a OR b OR c OR d ...
ALL = a AND b AND c AND d ...
So this behavior is just what "you would expect" if you have a math/cs background.