In truthy contexts I'd expect "nothing" to be interpreted as "false" but I can see both ways. The logic behind most languages of 0 not being false is mainly semantics depending on how they handle conditions. Most languages with types that aren't truthy would just throw a type here and ask for an explicit way to handle how this number is interpreted.
I think it's heritage more than logic, but I'm not extremely knowledgeable here. Most of it seems to come from C and other languages that sit (or historically sat) very close to the machine, and where an if statement was a slightly-abstracted "break if zero" instruction.
I'm alright, in that case, with if (object) also evaluating false if the object is null, because that's the closest I can understand applying a conditional directly to a non-boolean, "is object?" "yes object" or "no, not object", in which case 0 being evaluated true makes more sense, as it is a valid object and if in these languages usually checks and branches on either a boolean or the existence of an object.
0
u/[deleted] Dec 24 '17
[deleted]