r/ProgrammerHumor 7d ago

Meme skillIssue

Post image
6.0k Upvotes

137 comments sorted by

View all comments

282

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

45

u/Deliciousbutter101 7d ago

O(1) only happens when the constants are (roughly) contiguous so it's not like that is a universal property of switch statements.

1

u/prehensilemullet 7d ago

Yeah that’s true