-
Notifications
You must be signed in to change notification settings - Fork 0
plus plus Operator Issues
Christian Seidlitz edited this page Nov 23, 2022
·
1 revision
Did you know, that in #Powershell the ++
operator does not return a value per se?
Neither ++$x
nor $x++
will return anything!
However, if you put them in a calculation, or any other block that evaluates the whole statement again, you will get the expected results!
$x = 1; $x # -> 1
$x = 1; ++$x # -> nothing
$x = 1; $x++ # -> nothing
$x = 1; 1 + $x++ # -> 2
$x = 1; 1 + ++$x # -> 3
$x = 1; + $x++ # -> 1
$x = 1; + ++$x # -> 2
$x = 1; ($x++) # -> 1
$x = 1; (++$x) # -> 2