Created
March 26, 2013 19:06
-
-
Save dmgarland/5248211 to your computer and use it in GitHub Desktop.
Here is an example of a gist guessing game using a while loop....
This file contains 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
secret = rand(100) | |
print "Enter a number..." | |
while secret != (input = gets.chomp.strip.to_i) | |
puts "Wrong. Guess again..." | |
if secret > input | |
puts "I'll give you a clue... its higher..." | |
else | |
puts "I'll give you a clue... its lower..." | |
end | |
end | |
puts "You got it right..." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment