Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
example if/guard clause in Ruby
# verbose
if 2 + 2 == 4
puts "Correct!"
end
# short-hand
puts "Correct" if 2 + 2 == 4
# more realistic short-hand
def addition_problem(user_answer, correct_answer)
puts "Correct" if user_answer == correct_answer
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment