Flowdock
method

sample

Importance_1
Ruby latest stable (v1_9_3_392) - 0 notes - Class: Array
sample(p1) public

Choose a random element or n random elements from the array. The elements are chosen by using random and unique indices into the array in order to ensure that an element doesn’t repeat itself unless the array already contained duplicate elements. If the array is empty the first form returns nil and the second form returns an empty array.

If rng is given, it will be used as the random number generator.

Show source
Register or log in to add new notes.