scala运算符
The Scala programming language doesn't support unary operators (++ or --). In Scala, the binary operators are used to increment and decrement an integer.
Scala编程语言不支持一元运算符( ++或- )。 在Scala中,二进制运算符用于递增和递减整数。
Common binary operators for increasing and decreasing an integer, we use the increase and assign or decrease and assign operator.
对于增加和减少整数的常见二进制运算符,我们使用增加和分配或减少和分配运算符。
Increase and assignment operator : +=
增加和赋值运算符: + =
Decrease and assignment operator : -=
减少和赋值运算符: -=
Working example:
工作示例:
object myClass{
def main(args: Array[String]){
var a = 45 ;
println("initial value of a "+a)
// incrementing the value
a += 1
println("incremented value of a "+a)
// decreasnig the value
var b= 78
println("initial value of b "+ b)
b-=1
println("decremented value of b "+b)
}
}
Output
输出量
initial value of a 45
incremented value of a 46
initial value of b 78
decremented value of b 77
scala运算符