Skip to content

Instantly share code, notes, and snippets.

@MrBean83
Last active December 20, 2015 15:49
Show Gist options
  • Select an option

  • Save MrBean83/6157398 to your computer and use it in GitHub Desktop.

Select an option

Save MrBean83/6157398 to your computer and use it in GitHub Desktop.
"Build a simple guessing game"
class GuessingGame
def initialize(answer)
@answer = answer
end
def guess(guess)
@guess = guess
result = nil
case guess
when guess == @answer
result = :correct
when guess > @answer
result = :high
when guess < @answer
result = :low
end
result
end
def solved?
if @guess == @answer
true
else
false
end
end
end
@jhw1202
Copy link

jhw1202 commented Aug 5, 2013

My guess is a syntax error. Look through this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment