Skip to content

Instantly share code, notes, and snippets.

@jfrazee
Created August 19, 2013 16:37

Revisions

  1. jfrazee created this gist Aug 19, 2013.
    9 changes: 9 additions & 0 deletions tuple_to_args.scala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    // 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)