Skip to content

Instantly share code, notes, and snippets.

@leemour
Created February 14, 2014 12:42
Show Gist options
  • Save leemour/9000376 to your computer and use it in GitHub Desktop.
Save leemour/9000376 to your computer and use it in GitHub Desktop.
Loop until gets stop
Thread.new do
# Do this in a new thread so that the loop can run at the same time as gets (the latter waits until a newline is entered)
until gets.chomp == "stop"; end
# Exit the entire program (this only stops the current thread in IRB, I warn you)
exit
end
puts "Program started"
loop do
sleep 5
puts "Hello? Anyone here?"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment