Created
December 27, 2010 04:30
-
-
Save semanticart/755861 to your computer and use it in GitHub Desktop.
coffee-script handles ternaries poorly?
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
# I want to write | |
method = condition ? 'show' : 'hide' | |
# but that compiles to: | |
# var method; | |
# method = (typeof condition !== "undefined" && condition !== null) ? condition : { | |
# 'show': 'hide' | |
# }; | |
# so I have to use | |
method = if condition then 'show' else 'hide' | |
# to get | |
# var method; | |
# method = condition ? 'show' : 'hide'; | |
# or I can do | |
method = if condition | |
'show' | |
else | |
'hide' | |
# to get the same thing... am I missing something? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment