From: Cyent Date: 2005-05-07T08:59:23+09:00 Subject: Re: RCR 303: nil should accept missing methods and return nil On Sat, 07 May 2005 06:54:27 +0900, Florian Frank wrote: > 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. > > Great! I've so long waited for something like this. I have just written > a very reliable program, with this new feature: I presume the typo on @coutner was deliberate for illustrative purposes... Unfortunately rubies run time switches are bug compatible with perl's. If you read "man perl" and scroll down to the BUGS sections it says... BUGS The -w switch is not mandatory. Anybody who is vaguely worried about bugs in their code whether they are running perl or ruby should _always_ use the -w switch. ruby -w frank.rb frank.rb:29: warning: instance variable @counter not initialized frank.rb:29: warning: instance variable @counter not initialized frank.rb:29: warning: instance variable @counter not initialized frank.rb:29: warning: instance variable @counter not initialized frank.rb:29: warning: instance variable @counter not initialized frank.rb:29: warning: instance variable @counter not initialized frank.rb:29: warning: instance variable @counter not initialized frank.rb:29: warning: instance variable @counter not initialized frank.rb:29: warning: instance variable @counter not initialized frank.rb:29: warning: instance variable @counter not initialized frank.rb:25: warning: instance variable @counter not initialized Have done it times. -- 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.