I believe this was a design decision made by the PowerShell team to avoid surprises due to the PowerShell output return values. Many C / C # people expected that the following function would only output 1 not @ (0,1).
function foo { $i = 0 $i++ $i }
Thus, the form of the $i++ operator does not display the value of $ i until it is incremented. If you want this behavior, PowerShell allows you to get this behavior by placing the increment (or decment) statement directly in the expression, for example:
function foo { $i = 0 ($i++) $i }
This will exit @ (0,1).
Bruce Payette discusses this in Chapter 5 of Windows PowerShell in Action 2nd Edition . The increment and decrement operators are “exclusion statements”. Quote from the book:
This basically means that certain types of expressions, when used as statements, are not displayed. Invalid statements include assignment of operators and increment / decrement operators. Increments and decrements are used in the expression, they return a value, but when theyre used as a standalone operator, they do not return any value.
source share