madvoid:
Hi all,Can anyone help me understand what is going on in this line of code? I've never seen this kind of syntax before.
leap = yOff % 4 == 0;
That code says "The boolean (true/false) value of "leap" is equal to whatever "yOff modulo 4 == 0" evaluates to.
yOff modulo 4 means that yOff is looked at as a repeating sequence of 0, 1, 2 and 3. For example 0 == 0, 1 == 1, etc... 4 == 0, 5 == 1, etc. After you divide yOff by 4 as many times as you can, the REMAINDER is the result.
So, imagine that yOff was equal to "2000". 2000 modulo 4 is 0. Since "0 == 0" is true, the variable "leap" would be set to "true".
If yOff was equal to "2011", the modulo result would be 3. 3 is not equal to 0, to "leap" would be set to "false".
The whole line simply tells you "If year is a leap year, then "leap" equals "true", otherwise "leap" equals false".
Hope this helps.