From: Vince H&K Date: 2007-03-24T21:05:04+09:00 Subject: Re: Question about if in Ruby Trans wrote: > There is one other difference. > > if a = 1 > p a > end > > p a if a = 1 > > The later does not assign the a. This is not exactly true (at least on ruby 1.8.6): irb(main):001:0> if a = 1 irb(main):002:1> p a irb(main):003:1> end 1 => nil irb(main):004:0> p b if b = 2 NameError: undefined local variable or method `b' for main:Object from (irb):4 from :0 It doesn't create the variable b in the same scope as the one of the instruction. However: irb(main):007:0> a = 1 => 1 irb(main):008:0> p a if a = 2 2 => nil irb(main):009:0> a => 2 It does assign it if it already exists in the current scope. Works as well in ruby (it is not an irb artifact). Cheers, Vince -- Vincent Fourmond, PhD student (not for long anymore) http://vincent.fourmond.neuf.fr/