3 ms·
Indeed, it would be simpler if there was only "if" and no "unless", or multiple names for what are the same method (Array#size and Array#length), but (often) th
by jamesbritt 13y ago
Indeed, it would be simpler if there was only "if" and no "unless", or multiple names for what are the same method (Array#size and Array#length), but (often) they're there to make things easier to read and write.
- catnaroek 13y agoA more serious offender is the .to_s method: Why on earth is nil.to_is == "", but [nil].to_s == "[nil]"?
- danenania 13y agoWhat would you expect [nil].to_s to be? Seems like a reasonable representation to me. I certainly wouldn't want "['']", and I also wouldn't want nil.to_s to give me "nil". In practice having nil evaluate to an empty string is quite useful.
- catnaroek 13y agoI think nil.to_s == "nil" is pretty reasonable. At least, it gives .to_s an elegant definition that does not need to case-analyze the nil-ness of the elements of an array. In any case, this just reinforces my point that Ruby emphasizes ease of use, not simplicity.