Show 例子 5
优质
小牛编辑
131浏览
2023-12-01
例子 (Example)
以下示例显示如何在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}");
}
它将产生以下output -
a+=b : 15
a-=b : -1
a*=b' : 156
a/=b :0.9230769230769231
a%=b : 12