Scala Long &(x: Long) 方法
在 Scala 中,Long 是一个 64 位有符号整数,相当于 Java 的 long 原始类型。 &(x: Long)方法用于返回指定 Long 值和 Long 值的按位与。
Method Definition – def &(x: Long)
Returns – Returns the Bitwise AND of this value and x.
示例 #1:
// Scala program to explain working of
// &(x: Long) method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying &(x: Long) method
val result = (13.toLong).&(28:Long)
// Displays output
println(result)
}
}
输出:
12
示例 #2:
// Scala program to explain working of
// &(x: Long) method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying &(x: Long) method
val result = (7.toLong).&(11:Long)
// Displays output
println(result)
}
}
输出:
3