On page 85, regarding the code involving the lion, Line 1 in the 2nd paragraph reads, "First, lion is incremented and then returned to the expression, ", following which, it is mentioned that lion is decremented.
Is this an incorrect interpretation of the precedence of the post and pre-unary operators, or is the precedence of these operators ignored when they appear in the same line of arithmetic code and the compiler reads from left to right anyway?
Are you really sure about this erratum? In the original question, the order in which lion-- and ++lion were executed did not matter for the final result, since that was always 5. However, if you change lion-- into lion++, you can check how the expression is evaluated.
And the result is:
So it seems the explanation in the book is correct after all, but I'm inclined to agree that this example is too complex.
posted 1 week ago
Welcome to the Ranch
Yes, as we concluded earlier, the original explanation in the book appears to be correct.
Ruth Stout was famous for gardening naked. Just like this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!