Nothing says cleanup like nested ternaries. Average Nix code quality.
@delroth this is the nastiest usage of nested ternaries I've ever seen
@delroth @marisadoom not only that but now you have to memorize C++'s operator precendence to know what + "/builds" is being applied to ​
@delroth I really can't stand the type of dev who considers that a cleanup. It's usually a smartass techbro who thinks that this is a clever thing to do.
@delroth Confession. I love this shit. I think it's so much easier to read. Most people don't like this because they aren't used to the pattern.
@cbleslie @delroth I like single ternary ops, but I think this example is pretty bonkers, honestly :(
@srtcd424 @delroth That's okay! If you work on a project with more than one person, you need to make sure everyone can understand it. In this case, I would have left it how it was, because other people.
@cbleslie @delroth I also love nested ternaries like this. 🫣
In javascript I turn everything into a self-executing anonymous function to avoid doing this.
@catsalad @delroth let's start the nested ternary club.
@delroth I don't understand how the code on the right ended up on the right.
@gudenau @delroth I think if I was going to do something slightly cursed to this, I'd probably take the braces out from the ifs in version on the left .. only one line longer than the version of the right and more obvious imo.
@delroth what zero rust does to a mf
@delroth this but unironically
@delroth that ...is not a cleanup

this is what happens when people try to be clever and conflate "clean" to mean "compact" as opposed to "clear"
@delroth (random musing on my thoughts on code cleanness)

for me 'clean code' means that code being clear in what it does, or in other words code that you're able to understand what its doing at a glance without having to stop and mentally decode it

nested ternaries like this aren't clear, as they wrote it, it doesn't clearly separate at a glance 'condition' from 'return value', and it lacks clarity in what goes with what

the if (condition) return value pattern isn't the prettiest but its
clear, you can clearly distinguish each condition and its response

even as someone who've written similar compact code abominations, if i was writing code not just for myself, i'd go with plain old if statements because i'd want it to prioritize clarity over compactness or cleverness, the ternary pile is something i'd write for the funny in something i don't expect anyone else to read (and then hate myself when i have to figure it out again 3 months later)

@delroth I actually like the ternaries but 4 years of writing SystemVerilog may have rotted my brain

It should be aligned

a ? b : c ? d : e

though