From: "Ralph \"PJPizza\" Siegler" Date: 2005-06-02T01:22:03+09:00 Subject: Re: Method Chaining Issues On Thu, Jun 02, 2005 at 01:15:22AM +0900, aartist wrote: > try this: > string = "I am sold" > string.sub!('old','new').reverse!; > puts string > > It works. > > If string didn't contain the word 'old' then it will fail. > Is that a nice behavior? > Can it be changed to work on whatever input? > > Maybe this just shows that in-place modifying methods that can potentially return nil or an object without needed methods are too dangerous to chain for bullet-proof applications - in this case use .sub and .reverse with tests along the way