From: bbiker Date: 2007-07-24T10:44:57+09:00 Subject: Re: Is there a replacement for sub? On Jul 23, 4:38 pm, "Robert Dober" wrote: > On 7/23/07, bbiker wrote: > > > My primary objection to have a nil return is that it prevents me from > > safely chaining bang! methods. > > > The nil return is counter-intuitive and violates the Principle of > > Least Surprise > > Yours yes, mine not at all > > .. unless gsub!(..., ...) > > is quite useful to me. > well how about this counter example? str = "hello" str.downcase!.capitalize! => NoMethodError: undefined method `captitalize!' for nil:NilClass My point is that method chaining is a common ruby idiom and nil returns get in the way!!! I believe that there was/is a thread regarding chaining when a method returns nil. >> Hopefully Matz might be reading this thread and might consider >> changing the behavior of bang! methods returns. > > Why should he? He *might* consider it if it were a largely discussed > and backed up RCR, there seems some way to go... That's for sure. I know that I am whistling in the wind. :