Ruby | Random new() function Last Updated : 17 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report Random#new() : new() is a Random class method which creates a new PRNG using seed to set the initial state. Syntax: Random.new() Parameter: Random values Return: a new PRNG using seed to set the initial state. Example #1 : Ruby # Ruby code for Random.new() method # declaring Random value date_a = Random.new() # new arbitrary random state puts "Random new form : #{date_a}\n\n" Output : Random new form : # Example #2 : Ruby # Ruby code for Random.new() method # declaring Random value date_b = Random.new() # new arbitrary random state puts "Random new form : #{date_b}\n\n" Output : Random new form : # Comment More infoAdvertise with us Next Article Ruby | Range new() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Random-class Similar Reads Ruby | Random hex() function Random#hex() : hex() is a Random class method which checks returns a random hexadecimal string. Syntax: Random.hex() Parameter: Random values Return: a random hexadecimal string. Example #1 : Example for hex() method Ruby # Ruby code for Random.hex() method # loading library require 'securerandom' # 1 min read Ruby | Random new_seed() function Random#new_seed() : new_seed() is a Random class method which returns a random seed value. Syntax: Random.new_seed() Parameter: Random values Return: a random seed value Example #1 : Ruby # Ruby code for Random.new_seed() method # declaring Random value date_a = Random.new_seed() # new arbitrary ran 1 min read Ruby | Random ==() function Random#==() is a Random class method which checks whether the two random values are equal. Syntax: Random.==() Parameter: Random values Return: true - if random values are equal otherwise return false Example #1 : Ruby # Ruby code for Random.==() method # declaring Random value date_a = Random.new(1 1 min read Ruby | Random rand() function Random#rand() : rand() is a Random class method which generates a random value. Syntax: Random.rand() Parameter: Random values Return: generates a random value. Example #1 : Ruby # Ruby code for Random.rand() method # declaring Random value date_a = Random.rand() # new arbitrary random value puts 1 min read Ruby | Range new() function The new() is an inbuilt method in Ruby returns a new range of numbers. Syntax: range1.new(first, last) Parameters: The function accepts first and last which is the range that is to be created. Return Value: It returns the range of numbers. Example 1: Ruby # Ruby program for new() # method in Range # 1 min read Ruby | Random seed() function Random#seed() : seed() is a Random class method which returns seed value used to initialize the generator Syntax: Random.seed() Parameter: Random values Return: seed value used to initialize the generator Example #1 : Ruby # Ruby code for Random.seed() method # declaring Random value date_a = Random 1 min read Like