プロジェクト

全般

プロフィール

Vote #74699

未完了

Fix shadowing variable

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Text formatting_26
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
26
version_id:
0
issue_org_id:
15667
author_id:
73259
assigned_to_id:
0
comments:
2
status_id:
1
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
76
ステータス-->[New]

説明

fix using two different objects with same name, may cause problems


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.
--------------------------------------------------------------------------------

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0