Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

Relational Operators in Dart Programming



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 −

Operator Description Output
> Greater than x > y = false
< Less than x < y = true
>= Greater than or equal to x >= y = false
<= Less than or equal to x <= y = true
== Equal to x == y = false
!= Not equal to x != 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
Updated on: 2021-05-24T11:55:54+05:30

828 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements