Skip to content

Instantly share code, notes, and snippets.

@forforf
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save forforf/4980cf84910d2d00ea14 to your computer and use it in GitHub Desktop.
Save forforf/4980cf84910d2d00ea14 to your computer and use it in GitHub Desktop.
Ternary Style
# ternary approach
mood = day.is_sunny? ? 'good' : 'bad'
# if then else approach
mood = if day.is_sunny? then 'good' else 'bad' end
# boolean approach
mood = (day.is_sunny? && 'good') || 'bad'
# override approach
mood = 'bad'
mood = 'good' if day.is_sunny?
#multi-line approach
mood = if day.is_sunny?
'good'
else
'bad'
end
# others?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment