Ruby Random seed()函数
Random#seed() : seed() 是一个随机类方法,用于返回初始化生成器的种子值。
语法。随机.seed()
参数。随机值
返回:用于初始化发生器的种子值
例子 #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"
输出:
Random seed form : 14627199005973434753488768581471776591
Random seed form : 109687128738022354367166747684231621010
例子 #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"
输出:
Random seed form : 11386853110334908739001826239583965416
Random seed form : 191743863873657838482754700438995226369