Open In App
Related Articles

Ruby | Random seed() function

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
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 code for Random.seed() method
  
# declaring Random value
date_a = Random.new()
  
# declaring Random value
date_b = Random.new()
  
# seed value
puts "Random seed form : #{date_a.seed}\n\n"
  
puts "Random seed form : #{date_b.seed}\n\n"

                    
Output :
Random seed form : 14627199005973434753488768581471776591

Random seed form : 109687128738022354367166747684231621010

Example #2 :
# Ruby code for Random.seed() method
  
# declaring Random value
date_a = Random.new.seed
  
# declaring Random value
date_b = Random.new()
  
# seed value
puts "Random seed form : #{date_a}\n\n"
  
puts "Random seed form : #{date_b.seed}\n\n"

                    
Output :
Random seed form : 11386853110334908739001826239583965416

Random seed form : 191743863873657838482754700438995226369


Last Updated : 17 Dec, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads