Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Ruby | Random srand() function

  • Last Updated : 17 Dec, 2019

Random#srand() : srand() is a Random class method which returns system pseudo-random number.

Syntax: Random.srand()

Parameter: Random values

Return: system pseudo-random number.

Example #1 :




# Ruby code for Random.srand() method
  
# declaring Random value
date_a = Random.srand()
  
# new arbitrary random value
puts "Random form : #{date_a}\n\n"

Output :

Random form : 97145396384347815026726176289224049730

Example #2 :




# Ruby code for Random.srand() method
  
# declaring Random value
date_b = Random.srand(12)
  
# new arbitrary random value
puts "Random form : #{date_b}\n\n"

Output :

Random form : 275725175971615768898475651769765923352

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!