Skip to content

Instantly share code, notes, and snippets.

@dmgarland
Created March 26, 2013 19:06
Show Gist options
  • Save dmgarland/5248211 to your computer and use it in GitHub Desktop.
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....
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