From: Luke Graham Date: 2005-05-06T15:39:52+09:00 Subject: Re: RCR 303: nil should accept missing methods and return nil On 5/6/05, Stefan Lang wrote: > On Friday 06 May 2005 04:27, John Carter wrote: > > A very simple and generic way of improving the reliability of Ruby > > programs is to implement the NullObject pattern by allowing nil to > > accept all and every method instead of throwing a NoMethodError. > > > > Not only does this simplify ruby programs considerably, it also > > changes certain crash bugs silently into correct programs. > > I don't like it. It would hide many bugs. I want Ruby to throw an > exception when I'm ending up with something like that: > > some_var = some_method > # some_method *should* return an IO object, but this time > # it returned nil > some_var.puts "important data" > > It would be horribly if Ruby didn't throw an exception. John wants to be proven wrong with real code. (Well, Im sure he doesnt -want- to be proven wrong, but you know...). I can think of some artificial code that proves the point, but Im not sure its fair to post it. -- spooq