Created
December 10, 2013 13:16
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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