From: "marcandre (Marc-Andre Lafortune)" Date: 2013-02-24T13:00:14+09:00 Subject: [ruby-core:52779] [ruby-trunk - Bug #7935][Open] Array#sample with random generator Issue #7935 has been reported by marcandre (Marc-Andre Lafortune). ---------------------------------------- Bug #7935: Array#sample with random generator https://bugs.ruby-lang.org/issues/7935 Author: marcandre (Marc-Andre Lafortune) Status: Open Priority: High Assignee: Category: core Target version: next minor ruby -v: r39443 The Random generator method's rand is called with the wrong limit. Kernel::rand(n) returns integer between 0 and n-1, but generator is called with (n-1). For example: require 'delegate' [1, 2].sample(1, random: Random.new) # => [1], or [2] [1, 2].sample(1, random: SimpleDelegator.new(Random.new)) # => [1], never [2] test_random_ulong_limited -- http://bugs.ruby-lang.org/