Jay Taylor's notes
back to listing indexparameters - scala tuple unpacking - Stack Overflow
[web search]
I know this question has come up many times in different ways. But it is still not clear to me. Is there a way to achieve the following.
| |||||||||
| |||||||||
It's a two step procedure. First turn foo into a function, then call tupled on it to make it a function of a tuple.
| |||||||||||||
|
To respond to your comment:
In that case, this trick won't work. You can write a factory method in the companion object of your class and then obtain the tupled version of its
With
I know that's a lot of code duplication but alas... we don't have macros (yet)! ;) | |||||||||||||||
|
@dave-griffith is dead on. You can also call:
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
Wherein the curried version is invoked with multiple argument lists: scala> val c = foo _ curried c: (Int) => (Double) => Double =
Finally, you can also uncurry/untuple if needed.
| |||
add comment |