shuffle!()
public
Shuffles elements in self in place.
Show source
static VALUE
rb_ary_shuffle_bang(VALUE ary)
{
VALUE *ptr;
long i = RARRAY_LEN(ary);
rb_ary_modify(ary);
ptr = RARRAY_PTR(ary);
while (i) {
long j = (long)(rb_genrand_real()*i);
VALUE tmp = ptr[--i];
ptr[i] = ptr[j];
ptr[j] = tmp;
}
return ary;
}