Mysterious Trousers

Quality software and amazing support since 2010

We’re a small team dedicated to making you happy. We achieve this through synergizing analytics and best-of-breed social blah blah blah hard work and honest-to-goodness customer service.

Filtering by Tag: adam

Ternary shortcut

I use ternary operators everywhere, but I saw someone use this short cut and my mind was blown:

(a ? a : b) => (a ?: b)

Maybe I’m way behind, but I thought it was a neat trick.

This is similar to what I miss a lot in most interpreted languages:

a || b

And while we’re on the subject, coffescript doesn’t support ternary, but you can mock it like this:

(a ? a - c : b) => (a && a - c || b)

© 2013 Mysterious Trousers, LLC. All Rights Reserved. Background photo by hsld