Scala Long ==(x: Int)方法
在Scala中,Long是一个64位有符号整数,相当于Java的long原始类型。利用 ==(x: Int) 方法,如果该值等于x,则返回真,否则返回假。
方法定义 – def ==(x: Int):Boolean
返回 – 如果这个值等于x,则返回真,否则返回假。
例子 #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
极客教程