Skip to content

Instantly share code, notes, and snippets.

@ryanckulp
Created January 2, 2018 03:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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