Start the seed with the number 1 : rand « Development « Ruby






Start the seed with the number 1



srand 1
rand(1000)                         # => 37
rand(1000)                         # => 235
rand(1000)                         # => 908

# Reset the seed to its previous state
srand 1
rand(1000)                         # => 37
rand(1000)                         # => 235
rand(1000)                         # => 908

 








Related examples in the same category

1.Generating Random Numbers
2.Random with a range
3.Get a random item in an array
4.Get a random value in a hash
5.Generate random numbers
6.Some random numbers based on process number and current time