From: 7stud -- Date: 2008-01-25T05:02:08+09:00 Subject: Re: why must I initialize this variable? Gary Wright wrote: > Execution isn't moving backwards. You have to think of it as a two > step process, parsing then execution. The parser is going to prepare: > > puts "#{hi}" if (hi = "hello") > puts hi > > is such a way that the execution step sees: > > if (hi = "hello") > puts "#{hi}" > end > puts hi > > So during execution, nothing is going backwards. But the parser has > already tagged various parts of the code such that the 'hi' token in > the conditional is an local variable assignment from a literal (thus > the warning), the 'hi' token in the then clause as a method call, and > the 'hi' token on the final puts as a local variable. > > These three issues > 1) 0-argument method calls and local variables > are syntactically identical > 2) local variables don't have to be declared. > 3) Ruby's if/unless modifiers imply execution > order that is backwards from textual order > Thanks for the detailed explanation. :) > Another corner case is Yep, I already know about that one. -- Posted via http://www.ruby-forum.com/.