Re: Subclassing Struct.new
by Yukihiro Matsumoto other posts by this author
Feb 28 2006 6:22PM messages near this date
Re: Subclassing Struct.new
|
Re: Subclassing Struct.new
Hi,
In message "Re: Subclassing Struct.new"
on Wed, 1 Mar 2006 00:13:13 +0900, mental@[...].net writes:
|So, the current parsing rule is: "If you see an assignment to a bare
|name, that name means a variable until the end of the block/method.
|Until then it means a method call."
Yes, and in Ruby2.0, this will be changed to "if you see an assignment
to a bare name, that name means a variable in the current scope", so
that
| def foo
| n # method
| end
|
| def bar
| n = 3
| n # variable
| end
|
| def baz
| n # will be variable
| n = 3
| n # variable
| end
|
|Note that it doesn't matter if the assignment is actually performed,
|just that the parser sees it:
|
| def hoge
| n # will be variable
| if false
| n = 3
| end
| n # variable
| end
See?
matz.
Thread:
Minkoo Seo
Chiaro Scuro
Minkoo Seo
Yukihiro Matsumoto
Mark Wilden
Markus Werner
Chiaro Scuro
Minkoo Seo
Minkoo Seo
Hal Fulton
mental
Ross Bamford
mental
Ross Bamford
Chiaro Scuro
Ross Bamford
Chiaro Scuro
Minkoo Seo
Chiaro Scuro
mental
Chiaro Scuro
mental
Yukihiro Matsumoto
Caleb Clausen
Yukihiro Matsumoto
Caleb Clausen
MenTaLguY
Yukihiro Matsumoto
gwtmp01
Chiaro Scuro
mental
Chiaro Scuro
mental
Logan Capaldo
Pit Capitain
|