News for hackers. Stuff that matters.
Re:New Grad vs. Senior Dev by ericlippert on Saturday March 28, 2020 @12:07PM (#22711969)
Hint: what is the correct behaviour of this method when given empty strings? Every string contains the empty string as a substring.
Re:New Grad vs. Senior Dev by jpochtar on Saturday March 28, 2020 @12:17PM (#22712075)
Oh, I'd assumed disagreement on behavior of query="" between the two code samples meant it was UB and was looking for crashes/invalid memory accesses.
Re:New Grad vs. Senior Dev by ericlippert on Saturday March 28, 2020 @12:34PM (#22712212)
A Visual Basic program is not allowed to have undefined behaviours like a C program; InStr has a specification and that specification has to be implemented; that spec includes defining the behaviour for all inputs.

There's also no null handling here, which was a deliberate omission for clarity. In practice, the convention used inside the VB source code is that null string pointers are semantically the same as empty strings, which introduces some complexities.

Re:New Grad vs. Senior Dev by jpochtar on Saturday March 28, 2020 @12:37PM (#22712237)
ah neat, thanks!