Почему и как Scala обрабатывает кортеж специально при вызове функции с одним аргументом?

scala coalesces multiple function call parameters into a Tuple -- can this be disabled? discusses Scala creating a tuple to bind to one arg function. This results in

scala> println(1, 2)
(1,2)

The answer says that the compiler allows one arg functions to be called with no parens, so that logically this is a call to println with a tuple.

But println cannot be called with a single tuple parameter

scala> val t = (1, 2)
t: (Int, Int) = (1,2)

scala> println t
:6: error: value t is not a member of Unit
       println t
           ^

so something else is going on. Why are tuples special here?

13
задан Community 23 May 2017 в 10:28
поделиться