Anyway, I figured I would continue on my own and document my progress here, while making study notes.
Consider the following code for example:
someNumber = 25;
someVaraible = someNumber++ - 10
This code subtracts 10 from someNumber and then someNumber is increased by one. That’s easy the answer would be 16. No big deal right? But if you were to say have something a bit more involved like this:
someVariable = SomeNumber++ * 2 + 1; //this equals 10
4 * 2 = 8 + 1 = 9 + 1 (the postincrement++) = 10. Here the number is increase AFTER the calculation.
or if you do
someNumber = 4;
someVariable = ++SomeNumber * 2 + 1; //this equals 11
4 + 1(the ++preincrement) = 5 * 2 = 10 + 1 = 11 Here the number is increased BEFORE the calculation begins.
As you can see the placement matters. It affects the entire computation of the code! Now, as someone who is has not wrote vast amounts of code it is very easy to make a mistake, which would cause errors in my code. So I’m glad I’m they pointed this out with example code. I recreated my own example here so that I can have a more solid understanding before moving on. Hopefully this helps you too!