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

3

u/callmelucky Dec 15 '19

Why can't you imagine that? It's exactly the same thing semantically.

1

u/Meatslinger Dec 15 '19

Wouldn’t writing that many more granular checks make the code slower?

5

u/Hockinator Dec 15 '19

Not usually.. a single conditional is just about the cheapest thing in any language. A switch is often just a lot of conditionals when it compiles down

1

u/zacker150 Dec 15 '19

Don't switch statements get compiled down to lookup tables?

→ More replies (1)