Sunday, 15 March 2015

Scala: pass Seq to var-args functions -


Given a function that takes a variable number of arguments, e.g.

  def foo (os: string *) = println (os.toList)  

How do I cross the sequence of arguments of the function? I would like to write:

  val args = seq ("hi", "there") foo (args)  

Obviously, it does not work .

foo (args: _ *) moves a single argument Instead of applying the sequence in the form, each element in the sequence will be used as a logic.


No comments:

Post a Comment