Ternary operation in CoffeeScript Ternary operation in CoffeeScript javascript javascript

Ternary operation in CoffeeScript


Since everything is an expression, and thus results in a value, you can just use if/else.

a = if true then 5 else 10a = if false then 5 else 10

You can see more about expression examples here.


a = if true then 5 else 10a = if false then 5 else 10 

See documentation.


In almost any language this should work instead:

a = true  && 5 || 10a = false && 5 || 10