6 ms·
To me this comment is actually good evidence for why 0 shouldn’t be truthy. The reason you gave sounds like an anti-pattern that can only exist because 0 is tru
by aaachilless 9y ago
To me this comment is actually good evidence for why 0 shouldn’t be truthy. The reason you gave sounds like an anti-pattern that can only exist because 0 is truthy; so a good reason to have a falsy 0 is that you couldn’t do what you said you often do. In my opinion type checking should be more explicit than you’re comment suggests.
- boffinism 9y agoMaybe it's an antipattern to take "if x" to mean "if x is a numeric value". But if so it's surely more of an antipattern to take it to mean "if x is a numeric value that is not zero". I think the way out of this sort of antipattern, if antipattern it is, is to get rid of the idea of numeric values being truthy or falsey at all. I think your problem is with the whole concept of truthiness.
- traviscj 9y agoMore simple semantics are easier to understand. Ergo we should make the semantics as simple as possible. More complicated semantics save more words. Ergo we should make the semantics as complicated as possible. (This specific example is probably a false dichotomy--"the concept of truthiness" might be neither as simple nor as complicated as possible.)