Ruby didn't follow Perl at all though when it came to boolean evaluation. Perl considers "0" (the string containing the character 0) to be false (because there is no difference between "0" and 0). It has a special value, the string "0 but true", to allow returning a value that is numerically zero (and doesn't raise warnings when used as a number, unlike most strings that aren't numeric), but boolean true. Strings and numbers interoperate seamlessly depending on the operator used, super weakly typed.
Ruby went the opposite way, and said false and nil are falsy, everything else is truthy, and aside from that, all types are super strict (no adding numbers and strings at all, you need to convert explicitly).
44
u/American_Libertarian 23h ago
Same in Bash. Zero is truthy because executables exit 0 on success, and exit nonzero on error