From: dblack@... Date: 2002-11-27T08:15:57+09:00 Subject: Re: Default value of property Hi -- On Wed, 27 Nov 2002, Gavin Sinclair wrote: > From: > > > > [batsman:] > > > What's wrong about '? :' ? > > > > > > irb(main):001:0> b = nil > > > nil > > > irb(main):002:0> (__f=b)?__f.meth : nil > > > > Or: > > > > b.meth if b > > > > (if I'm understanding this part of the discussion correctly...) > > Your code is equivalent to batsman's, but the OP wanted a default value thrown > in, so: > > b and b.meth or default_value > > The original and the best! You mean you don't like: (b || Class.new.module_eval { def meth; "default value"; end; self }.new) .meth ?? :-) (It's been a long week....) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav