From: nobu@... Date: 2016-12-04T14:01:59+00:00 Subject: [ruby-dev:49895] [Ruby trunk Misc#13003] About not Random instance of random: keyword ardument of Array#shuffle! Issue #13003 has been updated by Nobuyoshi Nakada. バグでしょう。 https://github.com/ruby/ruby/compare/trunk...nobu:bug/calling-private-rand https://github.com/ruby/spec/compare/master...nobu:bug/calling-private-rand ---------------------------------------- Misc #13003: About not Random instance of random: keyword ardument of Array#shuffle! https://bugs.ruby-lang.org/issues/13003#change-61866 * Author: Makoto Kishimoto * Status: Open * 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/