Scala Int unary_- 方法与示例
unary_-方法用于返回带有负号的相同指定 int 值。
Method Definition: (Int_Value). unary_-
Return Type: It returns the same specified int value with negative sign.
示例 #1:
Scala
// Scala program of Int unary_-
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying unary_- function
val result = (65).unary_-
// Displays output
println(result)
}
}
Scala
// Scala program of Int unary_-
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying unary_- function
val result = (115).unary_-
// Displays output
println(result)
}
}
输出:
-65
示例 #2:
斯卡拉
// Scala program of Int unary_-
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying unary_- function
val result = (115).unary_-
// Displays output
println(result)
}
}
输出:
-115