Michael Turner wrote:
> 
> OK, here is a "real" beginners question, but interesting nonetheless:
> 
> Sample code:
> 
> $b = 1;
> $b = $b++;
> 
> Result:
> 
> $b = 1
> 
> Which strikes me as a little surprising. Shouldn't the result be 2? What
> is happening?

The simple answer is *DON'T DO THAT*.  :-)  In C, from whence the pre
and post increment are derived, this behavour is undefined.  In other
words, if you are going to use pre or post increment on a variable,
don't use that variable elsewhere in the same expression.

When you post increment a variable, the value of that variable is
returned and then the value is incremented.  When you pre increment a
variable, the value is incremented and the new value is returned.



John
-- 
use Perl;
program
fulfillment

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

Reply via email to