Note: the difference between '=' and '=='

Ben makes reference to the fact that an ‘if’ statement needs ‘==’ instead of just one ‘=’ while typing the following into the code: (at 5’29" in the current video for this lesson)

if (myState == States.cell) {

If I’ve been paying attention so far, this is the first place in the course that the difference between ‘=’ and ‘==’ is mentioned and I think it deserves more attention because it’s quite a fundamental concept in many computer languages.

In short, '=' is an operation; it actually makes a change to the thing on the left to make it equal to the thing on the right.

‘==’ is a comparison; it returns ‘TRUE’ or ‘FALSE’ depending on whether the things on either side are equal.

Monodevelop with C# will usually catch any mistakes where you get these the wrong way round. Other languages may not be so helpful…


Privacy & Terms