Scala Long ==(x: Int) 方法
在 Scala 中,Long 是一个 64 位有符号整数,相当于 Java 的 long 原始类型。如果该值等于 x,则使用==(x: Int)方法返回 true,否则返回 false。
Method Definition – def ==(x: Int): Boolean
Returns – Returns true if this value is equal to than x, false otherwise.
示例 #1:
// Scala program to explain the working
// of Long ==(x: Int) method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying ==(x: Int) function
val result = (12.toLong).==(8:Int)
// Displays output
println(result)
}
}
输出:
false
示例 #2:
// Scala program to explain the working
// of Long ==(x: Int) method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying ==(x: Int) function
val result = (13.toLong).==(13:Int)
// Displays output
println(result)
}
}
输出:
true