From: redmine@...
Date: 2011-04-20T23:31:07+09:00
Subject: [ruby-core:35833] [Ruby 1.9 - Bug #4590][Open] documentation is wrong for srand
Issue #4590 has been reported by Cezary Baginski.
----------------------------------------
Bug #4590: documentation is wrong for srand
http://redmine.ruby-lang.org/issues/4590
Author: Cezary Baginski
Status: Open
Priority: Low
Assignee:
Category: core
Target version:
ruby -v: r31311
'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
--
http://redmine.ruby-lang.org