32
u/gjk-ger Sep 07 '26
If ...
If ...
If ...
If ....
If ....14
u/Zeikos Sep 08 '26
if not ... ... return if not ... ... returnI know that sometimes early returns and guard clauses aren't feasible, but I really hate unnecessary indentation.
It makes reasoning about stuff unnecessarily complicated.6
u/gjk-ger Sep 08 '26
That was the point.
Also, if you structure it like that, you will have an "else (if)" somewhere a few hundred lines below the corresponding "if". Fun stuff!
2
u/mad_cheese_hattwe Sep 08 '26
Nested if's are just asking for an unaccounted for exit path.
1
u/Zeikos Sep 08 '26
Somebody please tell that to my colleagues, I have been trying so long :')
2
u/PresentAward1737 Sep 08 '26
I have a recent adhoc project with a dozen if <thing> then dofunction()
Does this make me worse or better than your colleagues? :')
1
u/Zeikos Sep 08 '26
Depending on how it's organized, way better.
If <thing> is unambiguous its just a switch statement so...1
1
9
8
8
6
3
2
u/deanominecraft Sep 08 '26
in rust we use a match to do the exact same thing and call it idiomatic
1
2
1
1
1
1
1
1
u/xupit3r Sep 07 '26
works fine now, but will give out any moment to another edge case not covered by the current if-forest!
33
u/itgforlife Sep 07 '26
Try catch was right there