IndexOf being weird? (Advent of Code day1 semi-spoiler?)
Okay I don't even know how to ask outside of "why?"
Why does this not find the index
24 Replies
sry I can get you the code in a sec, just I'm watching my friend code on a screenshare atm xD
is it your code or your friend's code? would be easier to help them directly
it's an error that came up while we were brainstorming Advent of Code together, but it's her code, I'll get her in the server in a sec just she is afk for a moment
it's really just 3 lines and I have no clue why indexof behaves like this
is the code being run the same as the code we're looking at?
yes
as in, are you sure the file is saved, the build succeeded, etc
yea, all of it went through green
we just made this file to see if the code/bug reproduces in a completely clean enviroment
the reason i'm asking is because the code shown is correct and works on my PC
so there is some other weird innate problem there
huh
or like "more in depth"
somehow you aren't running the code you think you are
hmmm
I don't know if a full shot of the screen helps in like "hah there should be another thing written"
but yea we'll be looking around, ty for confirming that the code works on other machines
(yea we just copied into an online interpreter and that worked too, damn)
she just confirmed that it is a fresh install of visual studio on the pc (one was installed previously, but it has been completely uninstalled before this)
TheRanger
REPL Result: Success
Console Output
Compile: 466.045ms | Execution: 28.790ms | React with ❌ to remove this embed.
works fine
yea for some weird reason, it works everywhere except on her pc xD
is the screenshot from her pc?
If its a locale issue, IndexOf takes a StringComparer: https://learn.microsoft.com/en-us/dotnet/api/system.string.indexof?view=net-8.0#overloads
is the computer perhaps running turkish locale? I know their locale has issues with specifically lowercase
i
Oh god. The Turkish I problem.
<flashbacks>
Use ordinal compare if at all possible
Or at least InvariantCulture
ur saying this exact code returns -1 in turkish locale?
I'm actually skeptical it's the Turkish I problem because it's such a rare edge case
if thats really the problem then ig thats not exactly the code their friend ran
this is why screenshots are bad