Why is there no Tuple1 Literal for single element tuples in Scala?

后端 未结 3 1170
野趣味
野趣味 2021-01-17 12:31

Python has (1,) for a single element tuple. In Scala, (1,2) works for Tuple2(1,2) but we must use Tuple1(1) to get a sin

3条回答
  •  庸人自扰
    2021-01-17 12:53

    Python is not statically typed, so tuples there act more like fixed-size collections. That is not true of Scala, where each element of a tuple has a distinct type. Tuples, in Scala, doesn't have the same uses as in Python.

提交回复
热议问题