5

So, I have a nested ternary, right, and that's not very readable:

(x <= y ? z : (x <= z ? y : x));

The linter points this out and I'm like yeah, valid point. So I inline-F[*0] it:

if (x <= y)
········return z;
else if (x <= z)
········return y;
else
········return x;

Clearer? Kinda. Oh, but the linter doesn't like this either, and to be fair, valid point once again; an else-after-return *can* be quite confusing if you have it in the __middle__ of the F body, catches you by suprise.

However, I'd like to take a brief moment to waggle your nutsack, if you please. Because this is C++ and I'm picking a reference from a list of values, so I can't simply assout[*1] within the switch.

So I'm at the crossroads of life once again, losing man's toughest struggle as I sit on a metaphorical cigar, squirming while I unclench my asshole slowly for strictly defecatory purposes. Allow me to illustrate:

- If I ignore the linter, and leave the rest of the code unchanged, the checks are going to fail and the bot is going to taint my pristine PR with automated comments.
- But if I take the linter's advice, I have to do a slight rewrite of the damn thing plus every F that calls it, which means touching shit that has nothing to do with this issue.

So what's it gonna be? Flushing or shoving my own excrement? Oh, the thrills of it being (literally) SOLID, ie not the acronym, but may the Almighty punish Uncle Bob regardless.

NOTES:
[*0]: It means 'function,' what else?
[*1]: ASS-ign OUT-put, where 'out' is just some var. You modify the var within the F body and return the final value.

Comments
  • 3
    That's high tide for a cheeky #pragma push(fuckyou) or #![alllow(fuck_you)] depending on your lang
  • 1
    I'm fairly sure that returning in an if-else-tree has some performance optimisations that can be applied that can't if you don't (e.g. tail call optimisation).

    I've never found if-return-else-return to be that difficult to read, and it's clearer to me that that is the intent and I can stop keeping those variables in memory. So I disagree with your linter
  • 2
    observe
  • 3
    you don't need else if you use return
  • 0
    I do exactly what @kiki does.

    But I'm totally fine with the ternary stuff. Only gets ugly when nested. But besides that it's very clear to me but not really in python tho. Hating ternary is just a thing people say because it's common or smth.

    Pony = x if a else b. I do "x or b". Had the same result, the first truthy get result.
Add Comment