The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

egbegb (2) [Avatar] Offline
#1
Got book. Great reading.

$d="$(1;2)"
$d
1 2
$e=0
$d="$($e++;$e)"
$d
1
What happened to the first expression in the "$($e++;$e)" line? Does
$e++ not evaluate to anything? If not how do I know if something evaluates
to something or not?
Kiron (38) [Avatar] Offline
#2
Re: Question
The increment/decrement operators don't return a value to the host when used as a stand alone statement only when they're used in an expression. Bruce explains better and why at the end of ยง 5.2, below table 5.2

Try this:

# Post-increment (possible gotcha)

$e = 0
while ($e++ -lt 5) {$e}
$e = 0
while ($e++ -le 5) {$e}

# Pre-increment:

$e = 0
while (++$e -le 5) {$e}
$e = 0
while (++$e -lt 5) {$e}