Scala Long /(x: Int) 方法
在 Scala 中,Long 是一个 64 位有符号整数,相当于 Java 的 long 原始类型。 /(x: Int)方法用于返回该值与给定值 x 的商。
Method Definition – def /(x: Int): Long
Returns – Returns the quotient of this value and 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 = (32.0021.toLong)./(8:Int)
// Displays output
println(result)
}
}
输出:
4
示例 #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 = (165.0123.toLong)./(13:Int)
// Displays output
println(result)
}
}
输出:
12