Open In App

Ruby | Random new() function

Last Updated : 17 Dec, 2019
Improve
Improve
Like Article
Like
Save
Share
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 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 : #


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads