In: |
rand.rb
|
Copyright (C) 2004 Ilmari Heikkinen <kig@misfiring.net>
Documentation: | Christian Neukirchen <chneukirchen@gmail.com> |
Calls block once for each element in self in random order, passing that element as a parameter.
# File rand.rb, line 25 25: def each_random(&block) 26: shuffle.each(&block) 27: end
Invokes block once for each element of self in random order. Creates a new array containing the values returned by the block.
# File rand.rb, line 31 31: def map_random(&block) 32: shuffle.map(&block) 33: end
Choose and return a random element of the Enumerable.
[1, 2, 3, 4].pick #=> 2 (or 1, 3, 4)
# File rand.rb, line 13 13: def pick 14: entries.pick 15: end