Ruby latest stable (v2_5_5) - 0 notes - Class: SecureRandom

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v2_2_9) is shown here.

These similar methods exist in v2_5_5:

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
Show source
Register or log in to add new notes.