From: mengx@... Date: 2002-01-03T03:17:43+09:00 Subject: [ruby-talk:30063] Re: A Bug or something else? > > m> What is opinion on the rationale of "nil" -> "" ? > > All objects in ruby can have a string representation. > They do need to have to string representation when needed. nil.inspect returns a reasonable string representation, and send "inspect/nil?" to nil is reasonable. But is it reasonable to send "to_s, to_i" to "nil"?. If o.nil? == true, special handling would have to be done (such as exiting process, raise exception, do assignment, call some functions..) so that "o" can become a meaningful object. e.g. a = {1=>2, 3=>4} "#{a[5]}" -> "" I assume people have similar program errors once in a while, (much like often stumbling on "a"[0] is not a char :-) which silently corrupts data. After finding such errors, usually some handling is done like the following: if a[5].nil? a[5] = 6 end "#{a[5]}" -> "6" With all this in mind, would you agree that at least for "nil", the built-in one should disable "to_s/to_i/to_a" as it does not seem to help in anyway to make correct program. Thanks -Ted