3 ms·
Why not: assert(someObj && someObj.data);
by cmovq 3y ago
Why not:
assert(someObj && someObj.data);
- maleldil 3y agoBecause that would be false if someObj is falsy. someObj => someObj.data, or !someObj || someObj.data (which are equivalent) would evaluate as true if someObj is falsy.
- clnq 3y agoThe point of implication is to say whether, in case P is true, that Q is true as well. If P is false, then the implication is always true. So it’s !P || Q. Or P=>Q as the author proposes. If(bValidate => IsValid()) { /* runs if either validation was unnecessary or passed */ } And that would be equivalent to (!bValidate || IsValid()).