Vote #74699
未完了Fix shadowing variable
0%
journals
I think it does not cause problem.
<pre><code class="ruby">
def test(text)
"test " + yield("yield " + text)
end
text = "aaaa"
text = test(text) do |text|
puts text
"block " + text
end
puts text
</code></pre>
<pre>
$ ruby a.rb
yield aaaa
test block yield aaaa
</pre>
r10209 has tests.
--------------------------------------------------------------------------------
yes, it isn't in this case, but may cause, because you create two different objects in same scope. Do you really think that's ok? Why do you rely on assumption that this piece of code will interprete right, instead of write it right?
and one more thing: code like this really hard to read, and maintain.
--------------------------------------------------------------------------------