Scala 的 Short -(x: Byte) 方法及其示例
-(x: Byte)
方法用于计算给定 Short 值与类型为 Byte 的 ‘x’ 的差值。
方法定义:def -(x: Byte): Int
返回类型:返回Int类型。
示例1:
// Scala program of -(x: Byte)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying -(x: Byte) method
val result = (995).-(126)
// Displays output
println(result)
}
}
869
示例2:
// Scala program of -(x: Byte)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying -(x: Byte) method
val result = (111).-(-126)
// Displays output
println(result)
}
}
237
阅读更多:Scala 教程