rand(*args) public

When the argument is an Integer or a Bignum, it returns a random integer greater than or equal to zero and less than the argument. Unlike Random.rand, when the argument is a negative integer or zero, it raises an ArgumentError.

When the argument is a Float, it returns a random floating point number between 0.0 and max, including 0.0 and excluding max.

When the argument limit is a Range, it returns a random number where range.member?(number) == true.

prng.rand(5..9)  #=> one of [5, 6, 7, 8, 9]
prng.rand(5...9) #=> one of [5, 6, 7, 8]
prng.rand(5.0..9.0) #=> between 5.0 and 9.0, including 9.0
prng.rand(5.0...9.0) #=> between 5.0 and 9.0, excluding 9.0

begin/end of the range have to have subtract and add methods.

Otherwise, it raises an ArgumentError.

Show source
Register or log in to add new notes.