Dart 编程 - 赋值运算符


例子

以下示例展示了如何在 Dart 中使用赋值运算符 -

void main() { 
   var a = 12; 
   var b = 3; 
     
   a+=b; 
   print("a+=b : ${a}"); 
     
   a = 12; b = 13; 
   a-=b; 
   print("a-=b : ${a}"); 
     
   a = 12; b = 13; 
   a*=b; 
   print("a*=b' : ${a}"); 
     
   a = 12; b = 13; 
   a/=b;
   print("a/=b : ${a}"); 
     
   a = 12; b = 13; 
   a%=b; 
   print("a%=b : ${a}"); 
}    

它将产生以下输出-

a+=b : 15                         
a-=b : -1                             
a*=b' : 156                                    
a/=b :0.9230769230769231                       
a%=b : 12
dart_programming_operators.htm