RAA - rand

rand / 0.9

Short description: Picking random elements and shuffling
Category: Library/Utility
Status: stable
Created: 2004-11-29 18:36:07 GMT
Last update: 2004-11-29 18:36:07 GMT
Owner: Ilmari Heikkinen (Projects of this owner)
Homepage: http://www.kronavita.de/chris/blog/static/projects/rand.html
Download: http://kronavita.de/chris/data/rand-0.9.0.tar.gz
License: Ruby's
Dependency:
None
Description:

Helper methods for Enumerable, Array, Hash, and String
that let you pick a random item or shuffle the order of items.

Examples with Array:

[1,2,3,4].pick
# => 2 (pick random element)

[1,2,3,4].shuffle
# => [2, 4, 1, 3] (return random-sorted version)

a = [1,2,3,4]
a.pick!
# => 3
a
# => [1,2,4] (remove the picked element)

Edit this project (for project owner)

back to RAA top