It appears that in Game Maker 8, 8.1, and Studio (at least) that the assignment operator =
is identical to the comparison operator ==
. For example, these lines do the same thing:
if (a=b) {}
if (a==b) {}
Is this function meant to be friendly to new users? Should I continue using ==
or switch to =
? Or does it make no difference?
P.S. Things like incrementing still work with =
similarly to ==
:
if a=b++{} //b is still incremented, but a does not change
This functionality was left over from previous versions as stated in the GameMaker help file.
"However, this is a legacy from old GameMaker versions and you should use the == operators for comparing and = for assigning."
It would be good practice for you to use ==
when comparing as that is what it is designed for. Also, if you were to move onto another languages like PHP, using the =
operator would actually initialize the variable in the if statement. This could give you quite a headache if you are in the habit of using the single =
operator.