Skip to content

Instantly share code, notes, and snippets.

@aldy505
Last active September 30, 2021 04:12
Show Gist options
  • Save aldy505/66d8ec07ec123d8eed35916dbfdb037a to your computer and use it in GitHub Desktop.
Save aldy505/66d8ec07ec123d8eed35916dbfdb037a to your computer and use it in GitHub Desktop.
Rust's Guessing Game in Ruby
randomNumber = rand(100)
puts "The random number is: #{randomNumber}"
correct = false
until correct do
print "Guess the number: "
input = gets
if input.to_i > randomNumber
puts "No, it's smaller than that. Try again."
next
elsif input.to_i < randomNumber
puts "No, it's bigger than that"
next
else
correct = true
break
end
end
puts "Yeah, you did it!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment