From: Hugh Sasse Staff Elec Eng Date: 2000-07-07T10:45:59+01:00 Subject: [ruby-talk:03893] Re: Array.uniq! returning nil On Fri, 7 Jul 2000, Yukihiro Matsumoto wrote: > If I create these methods from scratch, it is possible for me to make > the bang methods always return self. But CHANGING behavior will crash > fair amount of programs. Only options I can think of are: > > (a) introduce new methods (but not gsub!? please) > (b) introduce additional optional argument (as Hugh proposed in > [ruby-talk:03863]) Thank you. One more might be a new operator. I don't know what to call it so I will call it cut for now, for the sake of argument: a.modifier!().cut.method1.method2 where cut short-circuits the other methd calls if its receiver is nil. Otherwise it returns its receiver, passing it on for the subsequent methods. Then nil.cut would be like failure in Icon, the rest of the statement is not executed, but nobody gets upset about it. I think cut is the wrong name because cut is complelely different in prolog, IIRC, and it doesn't look like an operator. might look like a conditional cutting action.... Hugh hgs@dmu.ac.uk