Bug #4590
closeddocumentation is wrong for srand
Description
=begin
'ri srand' (in random.c) suggests that passing 0 generates a seed number:
If number is omitted or zero, seeds the generator using a combination of (...)}
Currently, this isn't true (0 is a valid seed):
srand(10); srand; srand
=> 290577086691033874500011807841900203857
srand(10); srand(0); srand(0)
=> 0
It should be:
If number is omitted, seeds the generator using a combination of (...)
I would normally create a patch for this, but wouldn't it be less surprising if srand accepted nil for generating the random seed?
Instead of code like:
prev_seed = (seed == nil ? srand : srand(seed))
we would have:
prev_seed = srand(seed)
Would this be a good idea?
Currently this fails, because an integer is expected:
srand(nil)
TypeError: can't convert nil into Integer
=end