Relational Operators

This class of operators contain those operators which are used to perform relational operation on the operands. It goes like this: 

Operator SymbolOperator NameOperator Description
>Greater thanCheck which operand is bigger and give result as boolean expression.
<Less thanCheck which operand is smaller and give result as boolean expression.
>=Greater than or equal toCheck which operand is greater or equal to each other and give result as boolean expression.
<=less than equal toCheck which operand is less than or equal to each other and give result as boolean expression.
==Equal toCheck whether the operand are equal to each other or not and give result as boolean expression.
!=Not Equal toCheck whether the operand are not equal to each other or not and give result as boolean expression.

Example showing the use of Relational Operators: 

Dart
// Dart Program Demonstrating use
// Of all Relational Operators
void main()
{
    int a = 2;
    int b = 3;

    // Greater between a and b
    var c = a > b;
    print("a is greater than b (a > b) : $c");

    // Smaller between a and b
    var d = a < b;
    print("a is smaller than b (a < b) : $d");

    // Greater than or equal to between a and b
    var e = a >= b;
    print("a is greater than b (a >= b) : $e");

    // Less than or equal to between a and b
    var f = a <= b;
    print("a is smaller than b (a <= b) : $f");

    // Equality between a and b
    var g = b == a;
    print("a and b are equal (b == a) : $g");

    // Unequality between a and b
    var h = b != a;
    print("a and b are not equal (b != a) : $h");
}

Output: 

a is greater than b (a > b) : false
a is smaller than b (a < b) : true
a is greater than b (a >= b) : false
a is smaller than b (a <= b) : true
a and b are equal (b == a) : false
a and b are not equal (b != a) : true

Note: == operator can’t be used to check if the object is same. So, to check if the object are same we use identical() function.

Operators in Dart

The operators are special symbols that are used to carry out certain operations on the operands. The Dart has numerous built-in operators which can be used to carry out different functions, for example, ‘+’ is used to add two operands. Operators are meant to carry operations on one or two operands. 

Similar Reads

Precedence Table of Operators in Dart

Description Operator Associativity unary postfix expr++ expr– () [] ?[] . ?. ! None unary prefix -expr !expr ~expr ++expr –expr await expr None multiplicative * / % ~/ Left additive + – Left shift << >> >>> Left bitwise AND & Left bitwise XOR ^ Left bitwise OR | Left relational and type test >= > <= < as is is! None equailty == != None logical AND && Left logical OR || Left if-null ?? Left conditional expr ? expr2 : expr3 Right cascade .. ?.. Left assignment = *= /= += -= &= ^= etc. Right...

Different types of operators in Dart

The following are the various types of operators in Dart:...

1. Arithmetic Operators

This class of operators contain those operators which are used to perform arithmetic operation on the operands. They are binary operators i.e they act on two operands. They go like this:...

2. Relational Operators

This class of operators contain those operators which are used to perform relational operation on the operands. It goes like this:...

3. Type Test Operators

This class of operators contain those operators which are used to perform comparison on the operands. It goes like this:...

4. Bitwise Operators

This class of operators contain those operators which are used to perform bitwise operation on the operands. It goes like this:...

5. Assignment Operators

This class of operators contain those operators which are used to assign value to the operands. It goes like this:...

6. Logical Operators

This class of operators contain those operators which are used to logically combine two or more conditions of the operands. It goes like this:...

7. Conditional Operators

This class of operators contain those operators which are used to perform comparison on the operands. It goes like this:...

8. Cascade Notation Operators:

This class of operators allows you to perform a sequence of operation on the same element. It allows you to perform multiple methods on the same object. It goes like this:...

Contact Us