Ruby for Instance / Timers

# Pause the execution of the current thread for 5 seconds
sleep(5)

loop do
  # Print the current time
  puts Time.now

  # Pause the execution of the loop for 1 second
  sleep(1)
end

# Register a block of code to be executed when the program exits
at_exit { puts "Goodbye!" }

Try on playground

Next: timeouts

made with by dfxe / source / license