'How to pass a sequence to a function accepting multiple arguments in Scala

Below are my 2 functions

def getProductAsDouble(nums: Double*):Double={
    var n = new BigDecimal("1.0")
    nums.foreach(num => n = n.multiply(new BigDecimal(num.toString)))
    n.setScale(2,java.math.BigDecimal.ROUND_HALF_UP).doubleValue()
  }

  def getProductAsString(nf:NumberFormat,nums: Double*): String ={
    nf.format(getProductAsDouble(nums)) // shows error here
  }

I am unable to pass nums from getProductAsString to getProductAsDouble. Is there any way to resolve this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source