Created
August 19, 2013 16:37
-
-
Save jfrazee/6271143 to your computer and use it in GitHub Desktop.
Convert tuples to scala arguments
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
// Just an ordinary function | |
def sum(x: Int, y: Int, z: Int) = x + y + z | |
// A tuple of arguments | |
val args = (1, 2, 3) | |
// Convert the function to a (partial) Function, which has a tupled method | |
// that takes tuples up to arity 5 | |
(sum _).tupled(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For scala 3 its simply,