Created
February 14, 2014 12:42
-
-
Save leemour/9000376 to your computer and use it in GitHub Desktop.
Loop until gets stop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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