Scala Double +(x: Double) 方法与示例
+(x: Double)方法用于查找参数中指定的 double 和给定的“x”类型 Double 的总和。
Syntax: def +(x:Double): Double
Returns: It return the sum of the specified double and the given double type ’x’.
示例 1:
// Scala program of +(x: Double)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying +(x: Double) method
val result = 3.56.+(2.34)
// Displays output
println(result)
}
}
输出:
5.9
示例 2:
// Scala program of +(x: Double)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying +(x: Double) method
val result = 4.940.+(2.394)
// Displays output
println(result)
}
}
输出:
7.3340000000000005