GridPosition.cs "Operator && cannot be applied..." error

So I’m guessing I made a mistake somewhere with the code, but I’m not seeing it.

VS is returning an error for the bool operator

public static bool operator ==(GridPosition a, GridPosition b)
    {
        return a.x == b.x && a.z = b.z;
    }

Not seeing what is causing the issue in the code.

(Edit Update)
Copying and pasting the same line from the Git resource, and the error goes away, looking at the two lines in Notepad++, it seems like VS’s auto formatting added a tabbed indent for some reason (probably user error/typo when I was using autocomplete) that was causing the problem.

(/Edit)

should be

a.z == b.z
2 Likes

Yeah, typo in my transcribed comment, but was correct in my code.

The only difference I could see was when I pasted both the git copy and my copy into Notepad++ was the tabbed-indent.

Even copying only the first line from my initial version, and retyping everything else 1:1 caused the problem.

Chalking it up to VS randomness and typos lol

Very strange, indentation is ignored in the compiler so that shouldn’t affect anything. Perhaps you had some invisible character in the code? Assuming you had == instead of = in the code everything looks correct, very weird.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms