From: Frederick Cheung Date: 2008-01-25T02:32:05+09:00 Subject: Re: why must I initialize this variable? On 23 Jan 2008, at 23:02, Curt Sampson wrote: > On 2008-01-23 02:40 +0900 (Wed), matt neuburg wrote: > >> puts "#{result}" if (result = h[k]) >> >> ...I get an error... >> Another way of understanding my confusion is to notice that this >> *does* >> work: >> >> if (result = h[k]) then puts "#{result}" end > > This is just one of those little annoyances in Ruby. You'll > find things like this all over the place. Another corner case is foo #=> NameError: undefined local variable or method `foo' for main:Object if false then foo=1;end foo #=> nil Fred > > > You may or may not get used to it. I never have, but I live with it > while waiting for the perfect language to come along. > > cjs > -- > Curt Sampson +81 90 7737 2974 > Mobile sites and software consulting: http://www.starling-software.com >