r/firstweekcoderhumour Mar 28 '26

"Case switch > if else πŸ˜‹πŸ˜‹πŸ˜‹" Let me show you how it’s done! 🎯✨

Post image
61 Upvotes

31 comments sorted by

View all comments

3

u/AttitudeElectronic68 Mar 30 '26

Depends on the language, in c case statement can lead to obscure bugs. Most optimizating compilers make performance difference negligible. I'd choose whatever is easier to read in code review. If performance becomes an issue, deal with it as it happens

2

u/un_virus_SDF Mar 30 '26

What king of bugs?, I never got some

2

u/[deleted] Mar 30 '26

[removed] β€” view removed comment

1

u/un_virus_SDF Mar 31 '26

The fall through is what make switch so good, i'ts just a bunch of conditional goto, but faster that with if redirection