Last active
August 29, 2015 14:01
-
-
Save forforf/4980cf84910d2d00ea14 to your computer and use it in GitHub Desktop.
Ternary Style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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