How to generate rand (random number) between two numbers?
I mean not between 0 and some number. It should be between some number (not 0)
and some number.
def range_rand(min,max)
min + rand(max-min)
end
This is the generally utility function I use. Throw in srand with a seed
if you’re using it for something related to security.
So you need to use rand with an integer argument - and if you do that
there is no point in picking another value than the range size.
You’ll end up with the solution Chris proposed.
Kind regards
robert
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.