From: Patrick Hurley Date: 2005-05-07T03:06:12+09:00 Subject: Re: Prove me Wrong! Re: RCR 303: nil should accept missing methods 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