红宝石 |随机 srand()函数
Random#srand() : srand()是一个 Random 类方法,它返回系统伪随机数。
Syntax: Random.srand()
Parameter: Random values
Return: system pseudo-random number.
示例 #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"
输出 :
Random form : 97145396384347815026726176289224049730
示例 #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"
输出 :
Random form : 275725175971615768898475651769765923352