Added to Favorites

Related Searches

Nearby Words

The spaceship operator is a binary relational operator that originated in the Perl programming language. Other languages, such as Ruby and Groovy also support the spaceship operator. It is written <=> . Unlike traditional equality operators, which will return 1 or 0 depending on whether the arguments are equal or unequal, the spaceship operator will return 1, 0, or -1 depending on the value of the left argument relative to the right argument. If the left argument is greater than the right argument, the operator returns 1. If the left argument is less than the right argument, the operator returns -1. If the two arguments are equal, the operator returns 0. In mathematics, this is known as the signum or Sign_function.## Example

The spaceship operator is primarily used for comparisons in sorting.

The spaceship operator takes its name because it looks like a small flying saucer as ASCII art. The term is now commonly used and the operator is referred by the name within the Perl documentation.

This operator is also used in ASCII-based mathematical notation to represent "less than, equal to or greater than", and is synonymous with the symbols ⋛ and ⋚. It can be used to test if the result of a calculation is actually a number.

Wikipedia, the free encyclopedia © 2001-2006 Wikipedia contributors (Disclaimer)

This article is licensed under the GNU Free Documentation License.

Last updated on Friday August 29, 2008 at 07:42:04 PDT (GMT -0700)

View this article at Wikipedia.org - Edit this article at Wikipedia.org - Donate to the Wikimedia Foundation

This article is licensed under the GNU Free Documentation License.

Last updated on Friday August 29, 2008 at 07:42:04 PDT (GMT -0700)

View this article at Wikipedia.org - Edit this article at Wikipedia.org - Donate to the Wikimedia Foundation

Copyright © 2014 Dictionary.com, LLC. All rights reserved.