Relational Operators in Dart Programming

Dart ProgrammingServer Side ProgrammingProgramming

Relational operators are used in cases where we want to compare two operands. The result when we use a relational operator between two operands is always a Boolean value.

There are different types of relational operators present in Dart. In the table shown below all the relational operators present in dart are mentioned.

Let's take a case where we have two variables x and y, with values 20 and 30 respectively.

Consider the table shown below as a reference −

OperatorDescriptionOutput
>Greater thanx > y = false
<Less thanx < y = true
>=Greater than or equal tox >= y = false
<=Less than or equal tox <= y = true
==Equal tox == y = false
!=Not equal tox != y = true

Let's make use of all these relational operators in dart.

Example

Consider the example shown below −

 Live Demo

void main(){
   var x = 20, y = 30;
   print("x > y is: ${x > y}");
   print("x < y is: ${x < y}");
   print("x >= y is: ${x >= y}");
   print("x <= y is: ${x <= y}");
   print("x == y is: ${x == y}");
   print("x != y is: ${x != y}");
}

Output

x > y is: false
x < y is: true
x >= y is: false
x <= y is: true
x == y is: false
x != y is: true
raja
Published on 24-May-2021 11:49:06
Advertisements