Hi,
In message "Re: Local variables & blocks"
on 03/01/30, ahoward <ahoward / fsl.noaa.gov> writes:
|> I may drop ':=' part, i.e.
|>
|> * block parameters are local to the block
|> * shadowing cause warnings
|> * no other way to make block local variables
|
|so, correct me if i am wrong, but this does not address the need to do
|
| x = nil
| a.each do |item|
| x = ...
| end
| p x
|
|does it?
It does. The key is:
* no other way to make block local variables
So that x in
a.each do |item|
x = ...
end
p x
would not be a block local variable. The code above will work without
preceding "nil" assignment.
matz.