I appreciate everyone who wrote, but I remain confused.

It seems to me that there is a weird short-circuit in the following code:

$b = 1;
$b = $b++;
print $b;

--> 1
I expected "2"

Whereas,

$b = 1
$b = ++$b;
print $b;

--> 2
As I expected.

I translate the autoincrement ($b++) as $b + 1, but post-increment 
doesn't seem to work when assigned to itself, whereas pre-increment 
does. So I was hoping for some confirmation that it is supposed to work 
that way, and perhaps why...

So while Connie & Dave & Chris have answered the question to a degree 
(and I thank them each), they haven't resolved my confusion.

It seems that '$b = $b++;' is always a coding mistake. Nobody should use 
that syntax on purpose, apparently, because it ignores the 'side effect' 
auto-increment. Is this true? I'll try to write my questions better in 
the future.

/Michael Turner


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to