Skip to content

Instantly share code, notes, and snippets.

@jfrazee
Created August 19, 2013 16:37
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfrazee/6271143 to your computer and use it in GitHub Desktop.
Save jfrazee/6271143 to your computer and use it in GitHub Desktop.
Convert tuples to scala arguments
// 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)
@Swoorup
Copy link

Swoorup commented Jan 8, 2022

For scala 3 its simply,

sum.tupled(args)

@chrislan815
Copy link

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment