Ruby's truthiness and coercion rules are one of the best and most consistent ones. And definitely the best in the dynamic languages I know, and I know quite a few.
Treating zero as false was only a thing because in C int was the base type, and other types (char, bool, pointer) were all expressed in terms of ints. It kind of made sense then. But now we know very well that abstraction that separates us from the hardware is a good thing. And with this assumption, treating zero as false is only a stale habit from the ancient days. Let alone monstrosities like treating 0.0 as falsy. Ruby did exactly the right thing here by cutting all that crap.
2
u/Vollgrav 16h ago
Ruby's truthiness and coercion rules are one of the best and most consistent ones. And definitely the best in the dynamic languages I know, and I know quite a few.
Treating zero as false was only a thing because in C int was the base type, and other types (char, bool, pointer) were all expressed in terms of ints. It kind of made sense then. But now we know very well that abstraction that separates us from the hardware is a good thing. And with this assumption, treating zero as false is only a stale habit from the ancient days. Let alone monstrosities like treating 0.0 as falsy. Ruby did exactly the right thing here by cutting all that crap.