/* * call-seq: * srand(number=0) => old_seed * * Seeds the pseudorandom number generator to the value of * <i>number</i>.<code>to_i.abs</code>. If <i>number</i> is omitted, * seeds the generator using a combination of the time, the * process id, and a sequence number. (This is also the behavior if * <code>Kernel::rand</code> is called without previously calling * <code>srand</code>, but without the sequence.) By setting the seed * to a known value, scripts can be made deterministic during testing. * The previous seed value is returned. Also see <code>Kernel::rand</code>. */ static VALUE rb_f_srand(argc, argv, obj) int argc; VALUE *argv; VALUE obj; { VALUE seed, old; rb_secure(4); if (rb_scan_args(argc, argv, "01", &seed) == 0) { seed = random_seed(); } old = rand_init(seed); return old; }