Scala short &(x: Byte): Int
Short是一个16位有符号整数类型,是scala.AnyVal的一个子类型(类似于Java的short原始类型)。&(x: Int)方法用于返回指定Byte值和Int值进行按位AND操作的结果。
方法定义:def +(x: Byte): Int
返回类型:它返回Int类型。
示例#1:
// Scala program of Short &(x: Byte)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying Short &(x: Byte) function
val result = (998.toShort).&(125:Byte)
// Displays output
println(result)
}
}
输出:
100
示例#2:
// Scala program of Short &(x: Short)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying Short &(x: Short) function
val result = (-111.toShort).&(47:Byte)
// Displays output
println(result)
}
}
输出:
1
阅读更多:Scala 教程