From: Cyent Date: 2005-05-07T09:09:24+09:00 Subject: Re: Prove me Wrong! Re: RCR 303: nil should accept missing methods On Sat, 07 May 2005 03:06:12 +0900, Patrick Hurley wrote: > On 5/5/05, John Carter wrote: >> I would suggest next 5 times you have a nil class throws >> NoMethodError crash, just add this at the head of your program... >> >> class NilClass >> def method_missing( sym, *args) >> nil >> end >> end >> >> And see what happens. >> >> If, your program then works correctly, then I am right. >> >> If, your still program thows an exception or reports an error, but perhaps >> a slightly different point, then I am still right, namely this change >> doesn't hide bugs. >> >> If the program silent proceeds to do the wrong thing, then I am wrong. > > > A simple example of "wrong" behavior (using the nil returns of ! > methods which is another can of worms :-) > > class NilClass > def method_missing(sym, *args) > nil > end > end > > x = "Pat" > x.strip!.upcase! > > #use x in some important way.... > # this now fails silently, the expectation > # was for an upcased string with no "extra" white space.... > puts x That's not a failure, thats a confirmation. You asked for an upcase string with no whitespace. You have got one. Wheres the problem? You didn't ask for a non-empty string... -- John Carter The Cybernetic Entomologist - cyent@xtra.co.nz http://geocities.yahoo.com/cy_ent I'm becoming less and less convinced of humans as rational beings. I suspect we are merely meme collectors, and the reason meme is only kept on to help count our change.