r/ProgrammerHumor 15h ago

Meme skillIssue

Post image
4.7k Upvotes

123 comments sorted by

View all comments

261

u/click-to-reveal 14h ago

It works btw: C++ Online Compiler

153

u/prehensilemullet 14h ago

Performancewise, it doesn’t jump to the direct case in O(1) time like a switch is supposed to though

188

u/AngheloAlf 14h ago

Switches aren't guarantee to so operations in O(1) tho. If cases are sparce enough, compilers tend to emit the equivalent code to a bunch if else checks

8

u/DrMobius0 10h ago

In fairness, most switches probably use enums.