From: ts Date: 2001-09-19T01:00:52+09:00 Subject: [ruby-talk:21336] Re: if before or if after? >>>>> "P" == Paul Brannan writes: P> x = '' if not defined?(x) At compile time, `x' is resolved as a local variable (ruby has seen an assignement). A local variable is always defined. P> if not defined?(x) then x = '' end p x At compile time the first `x' is resolved as a method call (this is the first time than ruby see it). Because there is no method #x, defined?(x) return nil. The second occurence (x = '') is resolved as an local variable. The third occurence (p x) is resolved as an local variable because ruby has seen the x = '' P> x = '' if not defined?(x) P> if not defined?(x) then x = '' end P> p x This is always the local variable `x' which is referenced. Guy Decoux