Consider the following example:
scala> def mult = (x: Int, y: Int) => x * y mult: (Int, Int) => Int scala> val list = List(1, 2, 3) list: List[Int] = List(1, 2, 3) scala> list zip list map mult <console>:10: error: type mismatch; found : (Int, Int) => Int required: ((Int, Int)) => ? list zip list map mult ^ scala> list zip list map mult.tupled res4: List[Int] = List(1, 4, 9)
There are many situations when you finish pairing elements in tuples. In such situations, you will need a correction function. But there are many other places where this is not so! For instance:
scala> list.foldLeft(1)(mult) res5: Int = 6 scala> list.foldLeft(1)(mult.tupled) <console>:10: error: type mismatch; found : ((Int, Int)) => Int required: (Int, Int) => Int list.foldLeft(1)(mult.tupled) ^
Thus, in principle, Scala has a dichotomy between tuples and parameters, which means that you need to convert functions from root to undisclosed and vice versa here and there.
source share