Skip to content

Instantly share code, notes, and snippets.

@FGRibreau
Created December 10, 2013 13:16
Show Gist options
  • Save FGRibreau/7890421 to your computer and use it in GitHub Desktop.
Save FGRibreau/7890421 to your computer and use it in GitHub Desktop.
Scala equivalent of JavaScript ~.apply and Python unpacking http://blog.fgribreau.com/2013/12/scala-equivalent-of-javascript-apply.html
def print[A](params:A*) = params.foreach(println)
// Below, every call to our print function are equivalent
// apply an array of arguments
val params = Seq(1,2,3)
print(params: _*)
// apply an array of arguments
print(Seq(1,2,3): _*)
print(1,2,3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment