From: Run Paint Run Run Date: 2009-08-02T07:35:50+09:00 Subject: [ruby-core:24677] [Bug #1858] Random#int's Handling of Invalid Arguments Contradicts its Documentation Bug #1858: Random#int's Handling of Invalid Arguments Contradicts its Documentation http://redmine.ruby-lang.org/issues/show/1858 Author: Run Paint Run Run Status: Open, Priority: Normal Category: core ruby -v: ruby 1.9.2dev (2009-08-01 trunk 24343) [i686-linux] The documentation for Random#int claims that it will raise an ArgumentError when the argument is 0 or negative. In fact, 0 causes repeated generation of 0, and for negative numbers the sign appears to be ignored. >> prng = Random.new(2) => # >> 20.times.map { prng.int(0) } => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] >> prng = Random.new(2) => # >> 20.times.map { prng.int(-4) } => [0, 3, 1, 0, 2, 3, 2, 3, 0, 3, 2, 1, 3, 3, 1, 3, 3, 3, 2, 0] Could this contradiction be addressed? Further, I'd suggest that Random.new.int(1) also raises an ArgumentError as it's meaningless to generate a pseudo-random integer between 0 and 1. ---------------------------------------- http://redmine.ruby-lang.org