Skip to content
class method

Random.seed

Random.seed → integer

Returns the seed value used to initialize the Ruby system PRNG. This may be used to initialize another generator with the same state at a later time, causing it to produce the same sequence of numbers.

Example
Random.seed      #=> 1234
prng1 = Random.new(Random.seed)
prng1.seed       #=> 1234
prng1.rand(100)  #=> 47
Random.seed      #=> 1234
Random.rand(100) #=> 47
See also #seed .rand .srand .new_seed also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0