Scala short &(x: Int):Int
Short,一个16位有符号的整数(相当于Java的short原始类型)是scala.AnyVal的一个子类型。利用&(x: Int)方法,可以返回Int值对指定Int值进行位数和运算的结果。
方法定义: def +(x: Int):Int
返回类型。它返回Int。
例子 #1:
// Scala program of Short &(x: Int)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying Short &(x: Int) function
val result = (998.toInt).&(1000:Int)
// Displays output
println(result)
}
}
输出。
992
例子#2。
// Scala program of Short &(x: Int)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying Short &(x: Int) function
val result = (111.toInt).&(1000:Int)
// Displays output
println(result)
}
}
输出。
104