Hi,
In message "[ruby-talk:5655] Re: local variables (nested, in-block, parameters, etc.)"
on 00/10/18, Mathieu Bouchard <matju / cam.org> writes:
|Yes, I'm lazy.
|
|And rewriting it to:
|
|x = [1,2,3].find {|i| condition i }
|
|is easy, and allows you to be lazier.
Well, it's definitely concise and better.
But lazy person like me prefer no work at all.
Anyway, I understand your opinion that block parameters should be
local. By the way, what do you think about the for-loop variable,
which is syntactically block parameter without blocks.
For example,
index = 345
for index in 1..5
print "#{index}\n"
end
print index # Prints 5
is almost identical to
index = 345
(1..5).each do |index|
print "#{index}\n"
end
print index # Prints 5
except the former does NOT introduce any block scope.
matz.