From: matz@... (Yukihiro Matsumoto) Date: 2001-09-19T01:21:49+09:00 Subject: [ruby-talk:21339] Re: if before or if after? Hi, As a general rule, a local variable start to exist when an assignemt to the variable is seen first, even if the assignemt is not executed at runtime. In message "[ruby-talk:21332] if before or if after?" on 01/09/19, Paul Brannan writes: |(1) If I do this: | | x = '' if not defined?(x) | p x 'x' start to exist at "x=''", so that defined?(x) is always true. |(2) But if I do this: | | if not defined?(x) then x = '' end A local variable 'x' is not exist at "defined?(x), so it's always false (unless it is defined previously). |(3) But, if I do this: | | x = '' if not defined?(x) | if not defined?(x) then x = '' end | p x 'x' start to exist at "x=''", so that both defined?(x) is always true. |What's going on here? Do you get it? matz.