Bug #1855: Random#int with Single-Element Ranges
http://redmine.ruby-lang.org/issues/show/1855

Author: Run Paint Run Run
Status: Open, Priority: Normal
ruby -v: ruby 1.9.2dev (2009-08-01 trunk 24343) [i686-linux]

Random#int accepts a Range argument from which it chooses values. If the range contains only one element, #int returns it on every call. This is unlikely to be what a user intended. I suggest that if the range's #begin value is equal to its #end value, an ArgumentError is raised.

  prng = Random.new
  => #<Random:0x9b446b0>
  >> 4.times.map { prng.int(2...3) }
  => [2, 2, 2, 2]


----------------------------------------
http://redmine.ruby-lang.org