[ruby-dev:50056] [Ruby trunk Misc#13003][Closed] About not Random instance of random: keyword ardument of Array#shuffle!
From:
mineroaoki@...
Date:
2017-03-29 08:28:37 UTC
List:
ruby-dev #50056
Issue #13003 has been updated by aamine (Minero Aoki). Status changed from Open to Closed This bug is already fixed, close. ---------------------------------------- Misc #13003: About not Random instance of random: keyword ardument of Array#shuffle! https://bugs.ruby-lang.org/issues/13003#change-63950 * Author: metanest (Makoto Kishimoto) * Status: Closed * Priority: Normal * Assignee: ---------------------------------------- Array#shuffle! の random: キーワード引数で、Randomのインスタンスでないような 任意のオブジェクトを渡してしまっていても、(最終的に)rb_random_ulong_limited 中の rb_funcallv(obj, id_rand, 1, &lim) という呼び出しによりグローバルの rand が 呼び出されて、それっぽく動いてしまいます。 わざわざ random: キーワード引数で渡していながら、変なオブジェクトを渡してしまって いる、というのは、ユーザのスクリプトのバグである可能性が高いと思うのですが、 それでもそれっぽく動いてしまうようになっている、というのは、そのように意図されて いるものでしょうか? -- https://bugs.ruby-lang.org/