3 ms·
In that case you can have the result of a function call be assigned to the const, and the function be the if/else for the value. With a well-named function it
by kevindamm 3y ago
In that case you can have the result of a function call be assigned to the const, and the function be the if/else for the value. With a well-named function it can even be more readable than the ternary.
- IlliOnato 3y agoHaving to create a function where a simple expression would suffice is "typing in mittens" programming...
- kevindamm 3y agoFair enough.. I actually use ternary sometimes, especially in brief return statements, and especially when both results are simple values. I only really avoid it when the result expressions are multiline. I just felt like pointing out the obvious when I saw GP's comment.