Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is x++ different from ++x?

I'm currently going through the Dynamics AX 2012 X++ developer E-learning and have a question about the X++ language that is not obvious from the documentation.

In one place it says that x++ and ++x are exactly the same. However it also has this statement where it talks about operator precedence:

  1. postfix operators [] . ( params ) expr ++ expr --

  2. unary operators ++ expr -- expr + expr - expr ~ !

So are they equivalent except for operator precedence or am I misunderstanding something?

Or does the fact that ++/-- are only used in statements and not expressions render all of this completely irrelevant?

like image 706
wax eagle Avatar asked Mar 19 '23 05:03

wax eagle


1 Answers

According to X++ documentation. The "++" operator can only be used as a statement. This restriction effectively trumps any operator precedence rules. My interpretation is that the "++" operator was included in the X++ precedence documentation for completeness.

like image 146
Chanicho Avatar answered Mar 23 '23 19:03

Chanicho