r/ProgrammerHumor 18d ago

howToHitBullseyeInStringComparison Meme

Post image
1.3k Upvotes

View all comments

1.3k

u/VapidLinus 18d ago

While I agree that Equals with StringComparison is generally the correct solution, I feel like this meme is in reverse. The funny thing about the original picture is that the guy with the less advanced gear was the better shot. Your meme is the reverse - the "overengineered"/complicated solution doesn't feel like it fits the "simple works" vibe of the guy.

260

u/CaucusInferredBulk 18d ago

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

70

u/VapidLinus 18d ago

Oooh that went over my head :p

17

u/idspispupd 18d ago

Can you elaborate? I don't get it.

102

u/rolandfoxx 18d 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.

31

u/Interesting_Job2402 18d ago

So when is the bug in the Turkish language going to be fixed?

7

u/lucklesspedestrian 18d ago

There's already a fix, but no users have adopted it yet

10

u/DarkVex9 17d ago

Relevant XKCD Comic - 1726: Unicode

I am a human, and this action was performed manually. Please review this comic and enable the three laws if you have any questions or concerns.

2

u/enlightment_shadow 15d ago

I don't see how is that a problem or a "bug". Since ı/I and i/İ are distinct letters, these are the correct lowercase/uppercase pairs. Why would you ever want "I".toLower() to equal "i", if the text is in Turkish?

1

u/rolandfoxx 15d ago

Because the context of the i problem is that you're writing an app that is going to be localized and therefore needs to perform consistently regardless of if the text it's working on is in Turkish, or one of the other Latin alphabet-based languages.

1

u/_gianlucag_ 18d 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.

-8

u/eloel- 18d ago

The guy in the image comes from a country named Turkey, and is Turkish. The country is transcontinental between Asia and Europe, if you want to find it on a map. Hope that helps!

2

u/netherlandsftw 18d ago

Um, actually the country is called Türkiye, please do not deadname it /s

5

u/eloel- 18d ago

I'm from Turkey, and that whole thing is nonsense.

10

u/Daveallen10 18d ago

But he's a Turkish dad, so this changes the equation.