wax eagle
wax eagle

Reputation: 541

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?

Upvotes: 4

Views: 343

Answers (1)

Chanicho
Chanicho

Reputation: 354

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.

Upvotes: 7

Related Questions