Method: Random.seed

Defined in:
random.c

.seedInteger

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.

Random.seed      #=> 1234
prng1 = Random.new(Random.seed)
prng1.seed       #=> 1234
prng1.rand(100)  #=> 47
Random.seed      #=> 1234
Random.rand(100) #=> 47

Returns:

[View source]

1343
1344
1345
1346
1347
1348
# File 'random.c', line 1343

static VALUE
random_s_seed(VALUE obj)
{
    rb_random_mt_t *rnd = rand_mt_start(default_rand());
    return rnd->base.seed;
}