Open In App

Ruby | Random srand() function

Last Updated : 17 Dec, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
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
# 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
# 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


Next Article

Similar Reads