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
广告