in reply to pre v.s. post (increment/decrement)

Ahhh ok. I think I finally get it. So it's like this: with pre-increment/decrement $i is immediately incremented/decremented and the value returned. Whereas with post-increment/decrement $i is evaluated first and then incremented/decremented accoringly, correct? So...
$i = 0; $j = ++$i; $i and $j are both 1 $i = 0; $j = $i++; $i is now 1 and $j is 0
P.S. Thanks for the speedy replies ^_^

Replies are listed 'Best First'.
Re: Re: pre v.s. post (increment/decrement)
by saintbrie (Scribe) on Jul 11, 2003 at 02:17 UTC

    Yes, that is correct. One cool use I've seen for post-increment is in object initialization when the Damien Conway prevents multiple inheritance:

    return if ($self->{_init}{Object}++);

    This returns control to the calling execution if the initializing function has already been called in the inheritance hierarchy. If it hasn't already been initialized, it increments and proceeds. If it has already been initialized, it returns.