Hacker News new | ask | show | jobs
by degif 2493 days ago
The same is in JavaScript:

  return (twitterUrl && config.twitter) || (githubUrl && config.github) || default
1 comments

Seems like an unnecessary mess when you could just use ternary expressions:

    return twitterUrl ? config.twitter
         : githubUrl ? config.github
         : default
I envy you, I’d love to grok ternary expressions better but every time I just end up having to spend a long time unrolling the logic.