return b ? x : y;
says "Here's where I return something, and here's what it is: a ternary expression.".
The other option is just a minified `if...else`. Sometimes you need to return inside a conditional, but I'd prefer not to. Having a single place where you return (or as few as possible) is nice.
If there are side-effects of building either of the values, or if there's other stuff happening that depends on the same conditional, then returning from an if/else would make sense.
Also, situations might come up where it's difficult or opaque to build one of the values in-line. If the values don't already exist as variables, and can't be built in-line, then one'll probably use the if/else format.
@DMN also thanks 😎
This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either!