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
on 2013-02-24 05:00
on 2013-02-24 15:06
Issue #7935 has been updated by nagachika (Tomoyuki Chikanaga). Assignee changed from mame (Yusuke Endoh) to nagachika (Tomoyuki Chikanaga) ---------------------------------------- Backport #7935: Array#sample with random generator https://bugs.ruby-lang.org/issues/7935#change-36932 Author: marcandre (Marc-Andre Lafortune) Status: Assigned Priority: High Assignee: nagachika (Tomoyuki Chikanaga) Category: Target version: 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
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.