DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Create A Random Number In Ruby

03.19.2010
| 2747 views |
  • submit to reddit
        Return a value from 0 to 5:
rand(6)

Return a value between 0 and 1:
rand

Resources:
 - <a href="http://ruby-doc.org/core/classes/Kernel.html#M005974">Module: Kernel</a> [ruby-doc.org]