📜  随机数 rails - Ruby 代码示例

📅  最后修改于: 2022-03-11 15:04:49.242000             🧑  作者: Mango

代码示例1
Use rand(range)

From Ruby Random Numbers:

If you needed a random integer to simulate a roll of a six-sided die, you'd use: 1 + rand(6). A roll in craps could be simulated with 2 + rand(6) + rand(6).

Finally, if you just need a random float, just call rand with no arguments.