Jim Lindley Notes

Array#rand

September 17th, 2007

Quickie: pick a random out of an array, or returns nil if the array is empty.

['my', 'little', 'pony'].rand # => 'pony'
['my', 'little', 'pony'].rand # => 'my'
[ ].rand                      # => nil

Changeset #7486

Sorry, comments are closed for this article.