in reply to
Code blocks with ternary operator or trailing conditionals
I’ll agree rather strongly with kcott and the others on this one: when the language fairly-obliges you to use a few “extra” keywords, do so. Why? Maybe because these “extra few” symbols serve to bypass ambiguities in the underlying grammar, such that there now becomes, and in the general(!) case, only one way that your intentions might be evaluated by the parser and so on. Every language has characteristics like this, somewhere in
the any every language. There will be a “right way” that might superficially seem odd or inconvenient. Why did they require that extra stuff? Maybe just because it made the grammar necessarily-stronger in a place where it truly needed to be stronger.
Also, think carefully about long-life maintainability of the code ... because computer software does have a very long life-span during which it will pass through many hands besides your own. It could well be that a future change to your code, if written in this way, could have unintended consequences that do not result in a syntax-error. (And this whether you were the one making the change, or not.) “Two paths diverged in a snowy wood,” and both were equally valid, and [Perl...] took the other one and raised no yellow flags. Maybe they affect the direct code-line that you are modifying at that time, but maybe they do not ... and does your project really have an all-encompassing test suite that is constantly maintained along with the code? Didn’t think so. So, this is just something that you should avoid as a matter of course, because hair-follicles are a precious thing . . .