The -- operator is the auto-decrement operator and is a common construct in modern programming languages, including C, PHP, VBScript, Java and JavaScript and Perl. 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, C, Java and PHP and the perlop manpage.

This has been a nodeshell rescue. Thanks to ariels for correcting a moderately bad braino on my part.

In the SQL-92 standard for SQL (Structured Query Language), placing -- before a single line of text comments it out (i.e. the code following it is not evaluated by the server). If placed in the middle of a line, -- comments out everything to the right of itself on that line. The one restriction is that placing the command GO on a line after -- will generate an error message. Comments like this are mostly used to document and explain stored procedures.

To comment out more than one line of text in SQL, it's better to use /* and */ at the beginning and end of the relevant section, rather than placing -- at the beginning of each line.

-- is also the one-line comment marker for Haskell, with {- and -} the multiline delimiters (thanks to resiak for this info).

-- is used to separate command line arguments from options.

Consider the following command:

ls -l

This will list the current directory lengthily. If you wanted to list the contents of a directory named -l, you would need to execute:

ls -- -l

Or to lengthily list the contents of a directory named -l, one would use:

ls -l -- -l

Log in or registerto write something here or to contact authors.