Equality and Relational Operators


Advertisements

Example

The following example shows how you can use Equality and Relational operators in Dart −

void main() { 
   var num1 = 5; 
   var num2 = 9; 
   var res = num1>num2; 
   print('num1 greater than num2 ::  ' +res.toString()); 
   
   res = num1<num2; 
   print('num1 lesser than  num2 ::  ' +res.toString()); 
   
   res = num1 >= num2; 
   print('num1 greater than or equal to num2 ::  ' +res.toString()); 
   
   res = num1 <= num2; 
   print('num1 lesser than or equal to num2  ::  ' +res.toString()); 
   
   res = num1 != num2; 
   print('num1 not equal to num2 ::  ' +res.toString()); 
   
   res = num1 == num2; 
   print('num1 equal to num2 ::  ' +res.toString()); 
} 

It will produce the following output

num1 greater than num2 ::  false 
num1 lesser than num2 ::  true 
num1 greater than or equal to num2 ::  false 
num1 lesser than or equal to num2  ::  true 
num1 not equal to num2 ::  true 
num1 equal to num2 ::  false 
dart_programming_operators.htm
Advertisements