4 ms·
That never stopped JavaScript, Python and friends from giving them equal truthiness.
by thirsteh 13y ago
That never stopped JavaScript, Python and friends from giving them equal truthiness.
- dragonwriter 13y ago> That never stopped JavaScript, Python and friends from giving them equal truthiness. Implicit casts -- including to booleans -- are dangerous, but if you try to write APIs to try to avoid every bad thing that might happen with naive use of implicit casting in every language that might be used to consume your API, you won't be able to do anything at all.
- X-Istence 13y agoEhm, Python doesn't have a NULL: >>> NULL == 0 Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'NULL' is not defined Even None, which is as close to NULL you are going to get in Python is not 0. >>> None == 0 False
- taway2012 13y agoThis is probably what the parent meant: >>> 'truthy' if None else 'falsy' 'falsy' >>> 'truthy' if False else 'falsy' 'falsy' >>> 'truthy' if 0 else 'falsy' 'falsy'
- aj 13y ago"truthiness" is true/false and NOT NULL! 0 != null null != false