From: dblack@... Date: 2002-11-27T04:32:55+09:00 Subject: Re: Default value of property Hi -- On Wed, 27 Nov 2002, Mauricio [iso-8859-1] Fern�ndez wrote: > On Tue, Nov 26, 2002 at 10:44:50AM +0900, ahoward wrote: > > On Tue, 26 Nov 2002, Tim Bates wrote: > > > > [snip] > > T> if object.property > > T> object.property.method > > T> else > > T> default_value > > T> end > > [snip] > > > > how about > > > > object.property and object.property.method or default_value > > > > you could do something like > > > > object.property.method rescue default_value > > > > but this does not catch NameError, unless someone else knows the syntax for > > this? > > 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...) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav