Skip to content

Instantly share code, notes, and snippets.

@bnadlerjr
Created August 11, 2010 04:00
Show Gist options
  • Save bnadlerjr/518454 to your computer and use it in GitHub Desktop.
Save bnadlerjr/518454 to your computer and use it in GitHub Desktop.
class Range
# Pick a random value from a Range.
# === Example
# (1..10).rand # => 3
def rand
a = self.to_a
a[Kernel::rand(a.size)]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment