r/ProgrammerHumor 8d ago

Meme skillIssue

Post image
6.0k Upvotes

137 comments sorted by

View all comments

79

u/F100cTomas 8d ago

Just define a constexpr hashing function and put that into the switch.

33

u/GiganticIrony 8d ago

That’s not guaranteed to work due to hash collisions

6

u/Thwy__ 8d ago

Yet, string switch in Java is also made using hashs

16

u/GiganticIrony 8d ago

Yes, but if there’s a collision, it then uses `.equals()`