From: Rick DeNatale Date: 2007-10-16T22:48:40+09:00 Subject: Re: nil.to_i returning zero On 10/16/07, Robert Dober wrote: > On 10/16/07, Rick DeNatale wrote: > > On 10/16/07, Robert Dober wrote: > > > The consequences would be that you code gets much more difficult to debug. > > > Good Rick never good fight with you, always agreed, now we can go for it ;) > > > I don't know that this is necessarily true. > > > > I'm not coming up with an example of code which this makes harder to > > debug, but that might just be a lack of imagination on my part. > Well I always forget to initialize my ivars and I get bitten late, I > guess if nil responds to messages it will take me about 10mins longer > to find the error (on average) but > extreme cases exist :(. But the idea of allowing a += 1 to set a to 1 when it's currently nil, just seems to me to be a nice enhancement to the lazy initialization 'pattern' fitting in with the well-known ruby lazy initialization idiom a ||= 1 When I first saw that last when I first encounterd Ruby, I smiled, realizing how much more I liked it than what I'd typed so many times in the past a isNil ifTrue:[a := 1] Which you should recognize from p. 85 of Kent's SBPP. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/