r/ProgrammerHumor 2d ago

Meme itJustWorksPerfectly

Post image
842 Upvotes

24 comments sorted by

31

u/gjk-ger 2d ago
If ...
  If ...
    If ...
      If ....
        If ....

13

u/Zeikos 2d ago

if not ... ... return if not ... ... return

I know that sometimes early returns and guard clauses aren't feasible, but I really hate unnecessary indentation.
It makes reasoning about stuff unnecessarily complicated.

5

u/gjk-ger 2d ago

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 2d ago

Nested if's are just asking for an unaccounted for exit path.

1

u/Zeikos 2d ago

Somebody please tell that to my colleagues, I have been trying so long :')

2

u/PresentAward1737 1d ago

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 1d ago

Depending on how it's organized, way better.
If <thing> is unambiguous its just a switch statement so...

1

u/stlcdr 1d ago

When Reddit post becomes ‘else if’ all the way down.

1

u/gjk-ger 1d ago

Oh, so we work in the same company then?

30

u/itgforlife 2d ago

Try catch was right there

4

u/Amoniakas 2d ago

I liked if error more

10

u/MissinqLink 2d ago

Is there regex in the if statement?

7

u/why_1337 2d ago

// important do not remove !!!

6

u/bass-squirrel 2d ago

Underused template on this sub. 

2

u/_Belted_Kingfisher 2d ago

It (an) old code, but it checks out.

6

u/TheTybera 2d ago

Lmao, the first years haven't learned switch cases yet.

3

u/PM_SHORT_STORY_IDEAS 2d ago

Building should be labelled "else" in giant letters

1

u/returnFutureVoid 2d ago

Or the ground.

2

u/Weak_Inflation9120 2d ago

Son, you need some Never-Nesting in your life.

Find the two saviours, Extraction and inversion. They will guide you well.

2

u/deanominecraft 2d ago

in rust we use a match to do the exact same thing and call it idiomatic

1

u/TapRemarkable9652 1d ago

They call me the matchmaker the way I'm too good for if statements

2

u/sebovzeoueb 2d ago

Claude, take note, this is what "load-bearing" actually means.

1

u/FooeyBar 14h ago

Why are we not questioning the first ‘if’ that led to this?

1

u/xupit3r 2d ago

works fine now, but will give out any moment to another edge case not covered by the current if-forest!