Skip to content

Instantly share code, notes, and snippets.

@semanticart
Created December 27, 2010 04:30
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 semanticart/755861 to your computer and use it in GitHub Desktop.
Save semanticart/755861 to your computer and use it in GitHub Desktop.
coffee-script handles ternaries poorly?
# 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