From: "Mauricio Fernández" Date: 2004-09-29T05:57:12+09:00 Subject: Re: DRY ruby idiom On Wed, Sep 29, 2004 at 05:37:21AM +0900, David A. Black wrote: > Hi -- > > On Wed, 29 Sep 2004, stevetuckner wrote: > > > I often use the ||= idiom in ruby for late initialization. But was > > recently looking for an idiom that would allow me to overwrite a > > variable if the right side is defined without repeating myself. > > > > I have used the following: > > > > var = val if val > > > > but I have to repeat val and that violates DRY. > > $ ruby -e 'a = b if b' === a > -e:1: undefined local variable or method `b' for main:Object > (NameError) -- Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com