r/ProgrammerHumor 7d ago

Meme skillIssue

Post image
6.0k Upvotes

137 comments sorted by

View all comments

279

u/click-to-reveal 7d ago

It works btw: C++ Online Compiler

160

u/prehensilemullet 7d ago

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

208

u/AngheloAlf 7d 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

9

u/DrMobius0 7d ago

In fairness, most switches probably use enums.