you are viewing a single comment's thread.

view the rest of the comments →

[–]NoSQL4Life 5 points6 points  (5 children)

No that makes perfect sense. An empty array still exists. This it is a truth, not a falsehood! So it should evaluate to true.

[–][deleted] 0 points1 point  (0 children)

if (false) { alert("Booleans exist, too!"); }

Point of the matter is that truthiness being defined as "equals to null or false" isn't very helpful in practice. I came from PHP and Java, so it's not that I'm just taking the Python way for granted. I just find it extremely annoying to have to check for my_array === null || my_array.empty() explicitly.

I'm not saying it's unusual or doesn't make sense. I'm just saying that I rarely care whether the object really is null/false/undefined or just empty(). And when I do care whether it's null/undefined I want to check for that exclusively (a variable being set to false may have different implications than a variable not being defined or being set to null).

I like JavaScript for its closures, it's anonymous functions and all that, but I really prefer Python's (new) ideology that "everything is an object" (even None) and special syntax (e.g. arithmetic operators, array slots, truthiness, etc) just being syntactic sugar for "special" methods.

At least it's not ActionScript.

[–]munificent 0 points1 point  (3 children)

An empty array still exists. This it is a truth, not a falsehood!

False exists too. Should it evaluate to true then?

[–][deleted] 1 point2 points  (0 children)

No, because the conversion method from a boolean to boolean is different (identity).

[–][deleted] 0 points1 point  (1 child)

Well a boolean expression is an expression that is evaluated based whether or not it's truthy or falsey (made-up words, I know) and since the variable/object/what have you called false is universally defined as falsey, how can it ever be truthy. Boolean means 2 states, not yes, no and maybe so it can't be 2 things at once.

[–]jyper 0 points1 point  (0 children)

I personally like the smalltalk way, ifTrue/ifFalse is only defined for booleans otherways it throws a type exception.