Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>@dave-griffith is dead on.</p> <p>You can also call:</p> <pre><code>Function.tupled(foo _) </code></pre> <p>If you want to wander into "way more information than I asked for" territory, there are also methods built into partially applied functions (and on <code>Function</code>) for currying. A few input/output examples:</p> <pre><code>scala&gt; def foo(x: Int, y: Double) = x * y foo: (x: Int,y: Double)Double scala&gt; foo _ res0: (Int, Double) =&gt; Double = &lt;function2&gt; scala&gt; foo _ tupled res1: ((Int, Double)) =&gt; Double = &lt;function1&gt; scala&gt; foo _ curried res2: (Int) =&gt; (Double) =&gt; Double = &lt;function1&gt; scala&gt; Function.tupled(foo _) res3: ((Int, Double)) =&gt; Double = &lt;function1&gt; // Function.curried is deprecated scala&gt; Function.curried(foo _) warning: there were deprecation warnings; re-run with -deprecation for details res6: (Int) =&gt; (Double) =&gt; Double = &lt;function1&gt; </code></pre> <p>Wherein the curried version is invoked with multiple argument lists:</p> <pre><code>scala&gt; val c = foo _ curried c: (Int) =&gt; (Double) =&gt; Double = &lt;function1&gt; scala&gt; c(5) res13: (Double) =&gt; Double = &lt;function1&gt; scala&gt; c(5)(10) res14: Double = 50.0 </code></pre> <p>Finally, you can also uncurry/untuple if needed. <code>Function</code> has builtins for this:</p> <pre><code>scala&gt; val f = foo _ tupled f: ((Int, Double)) =&gt; Double = &lt;function1&gt; scala&gt; val c = foo _ curried c: (Int) =&gt; (Double) =&gt; Double = &lt;function1&gt; scala&gt; Function.uncurried(c) res9: (Int, Double) =&gt; Double = &lt;function2&gt; scala&gt; Function.untupled(f) res12: (Int, Double) =&gt; Double = &lt;function2&gt; </code></pre> <p></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload