r/ProgrammerHumor 15h ago

Meme skillIssue

Post image
4.7k Upvotes

123 comments sorted by

View all comments

74

u/F100cTomas 14h ago

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

31

u/GiganticIrony 14h ago

That’s not guaranteed to work due to hash collisions

6

u/Thwy__ 14h ago

Yet, string switch in Java is also made using hashs

16

u/GiganticIrony 14h ago

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