method
shuffle!
v1_9_1_378 -
Show latest stable
- Class:
Array
shuffle!()public
Shuffles elements in self in place.
static VALUE
rb_ary_shuffle_bang(VALUE ary)
{
long i = RARRAY_LEN(ary);
rb_ary_modify(ary);
while (i) {
long j = rb_genrand_real()*i;
VALUE tmp = RARRAY_PTR(ary)[--i];
RARRAY_PTR(ary)[i] = RARRAY_PTR(ary)[j];
RARRAY_PTR(ary)[j] = tmp;
}
return ary;
} Related methods
- Instance methods
- &
- *
- +
- -
- <<
- <=>
- ==
- []
- []=
- abbrev
- assoc
- at
- clear
- collect
- collect!
- combination
- compact
- compact!
- concat
- count
- cycle
- dclone
- delete
- delete_at
- delete_if
- drop
- drop_while
- each
- each_index
- empty?
- eql?
- fetch
- fill
- find_index
- first
- flatten
- flatten!
- frozen?
- hash
- include?
- index
- initialize_copy
- insert
- inspect
- join
- last
- length
- map
- map!
- pack
- permutation
- pop
- pretty_print
- pretty_print_cycle
- product
- push
- rassoc
- reject
- reject!
- replace
- reverse
- reverse!
- reverse_each
- rindex
- sample
- select
- shelljoin
- shift
- shuffle
- shuffle!
- size
- slice
- slice!
- sort
- sort!
- take
- take_while
- to_a
- to_ary
- to_csv
- to_s
- to_yaml
- transpose
- uniq
- uniq!
- unshift
- values_at
- yaml_initialize
- zip
- |
- Class methods
- []
- new
- try_convert