Jus*_*ner 60
+= 是一个速记运算符.
someVar += otherVar
Run Code Online (Sandbox Code Playgroud)
是相同的
someVar = someVar + otherVar
Run Code Online (Sandbox Code Playgroud)
小智 15
使用以下形式的二元运算符的表达式:
x = x op y
Run Code Online (Sandbox Code Playgroud)
可以写成:
x op= y
Run Code Online (Sandbox Code Playgroud)
例如:
x += y # x = x + y
x /= y # x = x / y
x ||= y # x = x || y (but see disclaimer)
Run Code Online (Sandbox Code Playgroud)
但是,请注意,||=并且&&=可以略微行为......不同(与哈希索引器一起使用时最明显).尽管如此,还是有很多关于这种古怪的问题.
快乐的编码.
| 归档时间: |
|
| 查看次数: |
61892 次 |
| 最近记录: |