红宝石 |随机 new()函数
Random#new() : new()是一个 Random 类方法,它使用种子创建一个新的 PRNG 来设置初始状态。
Syntax: Random.new()
Parameter: Random values
Return: a new PRNG using seed to set the initial state.
示例 #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"
输出 :
Random new form : #
示例 #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"
输出 :
Random new form : #