From: dblack@... Date: 2007-05-22T21:44:30+09:00 Subject: Re: bug in ruby Hi -- On Tue, 22 May 2007, sairam MP wrote: > class Foo > attr_accessor :bar > > > def foo > self.bar = 1 > > > if false > bar = 2 # never executed > end > > > p self.bar # prints 1 > p bar # prints nil > end > end That's not a bug. The parser sees: bar = 2 and that triggers the allocation of bar. Since the expression is inside of the if false block, it never gets executed, so bar is nil. David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)