Scala: pass Seq to var-args functions -
given function takes variable number of arguments, e.g.
def foo(os: string*) = println(os.tolist)
how can pass sequence of arguments function? write:
val args = seq("hi", "there") foo(args)
obviously, not work.
foo(args:_*)
trick. instead of applying sequence 1 single argument, each element in sequence used argument.
Comments
Post a Comment