CoffeeScript doesn't have a ternary operator
CoffeeScript has no ternary operator! This blew me away, since CoffeeScript is so similar to Ruby.
In Ruby, a ? b : c
translates to: Is a
true? Ok, then return b
, otherwise I'll return c
.
In CoffeeScript, a ? b : c
translates to pure madness. If a
is not null
or "undefined"
, return a
. Otherwise, return an object literal ({ b: c })
...!?!
That's crazy.....so instead of using a ternary (which doesn't exist in CoffeeScript), call it a day with:
if a then b else c