mirror of
https://github.com/ruby/ruby.git
synced 2025-08-16 05:59:00 +02:00
* array.c (rb_ary_{shuffle_bang,sample}): use Random class object.
* random.c (try_get_rnd): use default_rand for Random as same as singleton methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
569d821929
commit
ae6a9009dc
3 changed files with 20 additions and 7 deletions
4
array.c
4
array.c
|
@ -3748,7 +3748,7 @@ static VALUE sym_random;
|
|||
static VALUE
|
||||
rb_ary_shuffle_bang(int argc, VALUE *argv, VALUE ary)
|
||||
{
|
||||
VALUE *ptr, opts, randgen = Qnil;
|
||||
VALUE *ptr, opts, randgen = rb_cRandom;
|
||||
long i = RARRAY_LEN(ary);
|
||||
|
||||
if (OPTHASH_GIVEN_P(opts)) {
|
||||
|
@ -3811,7 +3811,7 @@ static VALUE
|
|||
rb_ary_sample(int argc, VALUE *argv, VALUE ary)
|
||||
{
|
||||
VALUE nv, result, *ptr;
|
||||
VALUE opts, randgen = Qnil;
|
||||
VALUE opts, randgen = rb_cRandom;
|
||||
long n, len, i, j, k, idx[10];
|
||||
|
||||
len = RARRAY_LEN(ary);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue