To generate a random number between 3 and 10, for example, I use: rand(8) + 3
Is there a nicer way to do this (something like rand(3, 10)
) ?
To generate a random number between 3 and 10, for example, I use: rand(8) + 3
Is there a nicer way to do this (something like rand(3, 10)
) ?
For 10 and 10**24
See this answer: there is in Ruby 1.9.2, but not in earlier versions. Personally I think rand(8) + 3 is fine, but if you're interested check out the Random class described in the link.