Skip to content
Related Articles

Related Articles

Ruby | Random new() function
  • Last Updated : 17 Dec, 2019
GeeksforGeeks - Summer Carnival Banner

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 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 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 : #

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :