The -- operator is the auto-decrement
operator and is a common construct in modern programming languages
, including C
. Basically its effect is to reduce the numerical value of a variable by one. It has a different effect depending on how it is used:
$y = 5;
$x = $y--;
# $y is 4, but $x is 5.
compare to the following:
$y = 5;
$x = --$y;
# now both $x and $y are 4.
Using the -- operator after
the variable causes the decrement to occur after
the value is returned. Using the operator before
has the reverse effect.
The -- operator is the obverse of the ++
operator, which was inspired by the "newspeak
" in 1984
. Like ++
, -- has slipped into hacker and geek vocabulary
to indicate a perceived decrease in the value of the subject
See also ++
and the nodes on Perl
and the perlop manpage
This has been a nodeshell rescue. Thanks to ariels for correcting a moderately bad braino on my part.