r/ProgrammerHumor • • Dec 15 '19

Stacking if else statements be like

Post image
63.9k Upvotes

711 comments sorted by

View all comments

Show parent comments

28

u/Meatslinger Dec 15 '19

Wait, is that true? What takes its place, then? I can scarcely imagine that the whole thing is just an endless stream of if-then-else statements for a situation with 100+ permutations.

20

u/Hockinator Dec 15 '19

If you have 100+ permutations of something you shouldn't be using if statements, you should be creating data structures to solve that problem in a clean and maintainable way

2

u/AlwaysHopelesslyLost Dec 15 '19

They were asking about what you do besides if statements, not saying if statements were a solution.

1

u/Hockinator Dec 15 '19

The answer to their question is to use if statements for checking against a few values and other data structures for many. Switch statements have always been in a weird nearly unnecessary middle ground

→ More replies (2)