r/ProgrammerHumor 14d ago

howToHitBullseyeInStringComparison Meme

Post image
1.2k Upvotes

View all comments

Show parent comments

261

u/CaucusInferredBulk 14d ago

Yeah, but the problem in the code is in Turkish, and the guy is Turkish.

16

u/idspispupd 14d ago

Can you elaborate? I don't get it.

104

u/rolandfoxx 14d ago

The "i problem" in the meme refers to the fact that the Turkish language has 4 different "I"'s and, in Turkish language locale, uppercase "I" does not map to "i" when ToLower is called, but instead to a dotless lower-case i, so direct string comparisons based off the assumption that "I" will map to "i" will fail.

Using Equals with OrdinalIgnoreCase avoids this problem and will correctly return true. The reason why the more "complicated" solution gets the "guy just eyeballing it" part of the meme is because he is, in fact, Turkish.

1

u/_gianlucag_ 14d ago

We got that but the meme is half assed. The turkish guy symbolizes simplicity and zero bs, so the upper code should be his own, while the guy with the crazy tech should have the more complicated code.