From: Dave Thomas Date: 2000-12-22T16:10:03+09:00 Subject: [ruby-talk:7943] Re: defined? problem? Kevin Smith writes: > Not being a language designer, I would expect: > > something if condition > > to be absolutely identical in behavior to: > > if condition > something > end > > That is, I would think the if-modifier would just > be an alternate way of formatting the same code. > Apparently that's not the case here. Remember that Ruby creates a local variable when it first sees an assignment to it. The assignment does not have to be executed. The two options above differ in that in one the condition textually precedes the 'something' and in the other it follows it. Variables first assigned to in the 'something' will therefore be available to the condition in the modifier form, but not in the conventional form. Dave