From: ahoward Date: 2002-11-26T11:25:02+09:00 Subject: Re: Default value of property On Tue, 26 Nov 2002, Hal E. Fulton wrote: > I did try this, which doesn't work: > > x = obj.property.meth rescue default_value > > I'm not sure why it doesn't work, and I think > it would be nice if it did. rescue doesn't normally catch NameErrors this will work /scratch > irb irb(main):001:0> begin irb(main):002:1* foo irb(main):003:1> rescue NameError irb(main):004:1> puts 'did not define foo...' irb(main):005:1> end did not define foo... this won't irb(main):006:0> begin irb(main):007:1* foo irb(main):008:1> rescue irb(main):009:1> puts 'did not define foo...' irb(main):010:1> end NameError: undefined local variable or method `foo' for # from (irb):7 this has confused me on several occasions, though it kind of make sense... -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================