pass function arguments from a iterable in Scala?

arguments, function, scala

Solution

For it to work on lists you'll need to accomodate the `mysum` function to "varargs":

scala> def mysum ( args : Int* ) = args.sum
mysum: (args: Int*)Int

scala> val arguments = List(1,2)
arguments: List[Int] = List(1, 2)

scala> mysum(arguments: _*)
res0: Int = 3

Problem

Is it possible to pass function arguments from a iterable in Scala? ``` val arguments= List(1,2) def mysum(a:Int,b:Int)={a+b} ``` How would one call mysum using the List contents as arguments?

Original source

Related problems