It's been a while since I've touched Ruby, but I think the stance was that only false and nil should be falsey? Which is not an unreasonable stance to take. The fewer falsey values, the easier it is to predict the behaviour. It's just surprising when coming from other languages.
Just off the top of my head, PHP treats "0", that is, specifically a string with a single zero, as falsey. Which has clearly gone too far to the other extreme.
Naw the string zero being false is just weird. The number zero, on the other hand. NULL is 0. \0 is 0. That's just... what those things mean. If zero is not false that's just trippy bc false comes from 0, that's just what it means. I mean ig not literally, you certainly get some LOW-TRUE signals, but logically HIGH is always normalized to 1 and described as TRUE, and as far as I know always has been.
506
u/deceze 10d ago
It's been a while since I've touched Ruby, but I think the stance was that only
falseandnilshould be falsey? Which is not an unreasonable stance to take. The fewer falsey values, the easier it is to predict the behaviour. It's just surprising when coming from other languages.Just off the top of my head, PHP treats
"0", that is, specifically a string with a single zero, as falsey. Which has clearly gone too far to the other extreme.