2 ms·
Using -- for comments is a long-established convention: Ada, Eiffel, SQL... 0 (and everything but nil and false) is truthy is also pretty common in the Lisp wo
by int_19h 8y ago
Using -- for comments is a long-established convention: Ada, Eiffel, SQL...
0 (and everything but nil and false) is truthy is also pretty common in the Lisp world.
Side note: I actually find it ironic that Python of all languages does this implicit falseness thing on so many types, given that it puts "explicit is better than implicit" on its banner. I don't see the difference between treating an empty list as false when the context requires a Boolean value, and treating string '0' as numeric 0 when the context requires a numeric value.
And it can be a source of bugs - while there are many cases where an empty list and None are semantically equivalent, that's not always true. And it can be something that's very easy to forget when reading code that is broken that way (e.g. during code reviews). I'd much rather have functions like `is_none_or_empty`, `is_none_or_zero` etc that make it clear what the check is actually doing.