Actions
Bug #1855
closedRandom#int with Single-Element Ranges
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-08-01 trunk 24343) [i686-linux]
Backport:
Description
=begin
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]
=end
Actions
Like0
Like0Like0