Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A more serious offender is the .to_s method: Why on earth is nil.to_is == "", but [nil].to_s == "[nil]"?


What 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.


I 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: