--0016e65a0934d0186b048906c735
Content-Type: text/plain; charset=ISO-8859-1

On Mon, Jun 14, 2010 at 5:41 PM, Rick DeNatale <rick.denatale / gmail.com>wrote:

> This is close, except that it will blow up if x isn't already defined.
>
> another alternative might be
>
> (defined? x) ? (x || x  ) : y
>
> Which avoids the problem when x isn't defined, but isn't exactly what
> the 'compiled' ruby code does, whether that 'code' is YARV 'byte
> codes' or an AST in MRI pre 1.9
>
>
This implies to me that if x is not defined, then return y without modifying
x. But this contradicts the reason I used || or (lazy assignment).

$ irb


ruby-1.9.1-p378 > defined? x
 nil


ruby-1.9.1-p378 > defined? x
 nil


ruby-1.9.1-p378 > x || 
 5


ruby-1.9.1-p378 > x
 5

--0016e65a0934d0186b048906c735--