random_number(n=0)
Class Public methods
::random_number generates a random number.
If a positive integer is given as n, ::random_number returns an integer: 0 <= ::random_number < n.
p SecureRandom.random_number(100) #=> 15 p SecureRandom.random_number(100) #=> 88
If 0 is given or an argument is not given, ::random_number returns a float: 0.0 <= ::random_number < 1.0.
p SecureRandom.random_number #=> 0.596506046187744 p SecureRandom.random_number #=> 0.350621695741409
Please login to continue.