等式和关系运算符


例子

以下示例展示了如何在 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()); 
} 

它将产生以下输出-

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