Tell Ruby Program to Wait some amount of time

后端 未结 6 1316
渐次进展
渐次进展 2020-12-07 07:24

How do you tell a Ruby program to wait an arbitrary amount of time before moving on to the next line of code?

6条回答
  •  粉色の甜心
    2020-12-07 08:13

    I find until very useful with sleep. example:

    > time = Time.now
    > sleep 2.seconds until Time.now > time + 10.seconds # breaks when true
    

提交回复
热议问题