method
random_number
Ruby latest stable (v2_5_5)
-
0 notes -
Class: SecureRandom
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6
- 2_5_5
- 2_6_3
- What's this?
random_number(n=0)
public
SecureRandom.random_number generates a random number.
If a positive integer is given as n, SecureRandom.random_number returns an integer: 0 <= SecureRandom.random_number(n) < n.
p SecureRandom.random_number(100) #=> 15 p SecureRandom.random_number(100) #=> 88
If 0 is given or an argument is not given, SecureRandom.random_number returns a float: 0.0 <= SecureRandom.random_number() < 1.0.
p SecureRandom.random_number #=> 0.596506046187744 p SecureRandom.random_number #=> 0.350621695741409