From: Robert Dober Date: 2007-07-21T07:06:04+09:00 Subject: Re: RCR? Added syntax for chains that possibly return nil On 7/20/07, Trans wrote: > > > On Jul 20, 10:18 am, Trans wrote: > > On Jul 20, 9:36 am, Stefan Rusterholz wrote: > > > > > Trans wrote: > > > > Sure. I realize. I'm only pointing out that this -> operator is > > > > equivalent to a rescue NoMethodError, > > > > > So how can I explain to you that it *isn't*? > > > > Just tell me, how isn't it? The end result seems exactly the same me. > > How does: > > > > foo = (bar.baz default bar).quuz default quux > > > > differ in result from: > > > > foo = (bar->baz || bar)->quuz || quux > > I went back and reread the first post. You actually want it to only be > effective on nil. Okay, I see the basic difference. In my example if > bar.baz returned nil then the default quux would be the result. In > yours it would be bar. However, I'm not sure that's better. I can just > do > > foo = (bar.baz || bar).quuz default quux > > to get your behavior. But your technique can not do what mine can. > > T. > Yes indeed Stefan your idea is interesting Tom took it a step further, I do not like either of the syntaxes but these are two bright ideas nevertheless, I feel that the power of Tom's solution somehow justifies the syntax. Ara's point is important too, how big are chances that this syntax will be abused of? But it is not as important as it might seem at first sight as we have already shown that there are equivalent language constructs anyway... ... still thinking. > > Robert -- I always knew that one day Smalltalk would replace Java. I just didn't know it would be called Ruby -- Kent Beck