Not-equal operation

Learn how to check if a value is not equal to another.

The not equal operation checks whether two values are different. Unlike relational operations, it works on any value, not just values that have a concept of order.

To check whether two values are different, place the != operator between them:

/*<operand>*/ != /*<operand>*/
Try in Playground

Here's a practical example involving strings:

"hello" != "Hello" // true
Try in Playground

And another one involving numbers:

1 != 1.1 // true
Try in Playground

Although there is no natural language equivalent to the != operator, you can use the not equal to test for a more natural reading:

/*<operand>*/ is not equal to /*<operand>*/
Try in Playground

Note that operations and tests may differ in their behavior and precedence. Please refer to the documentation of each specific operation and test for more information.