Why do case classes extend only Product and not Product1, Product2, …, ProductN?

前端 未结 3 2319
一整个雨季
一整个雨季 2021-02-19 08:58

after I learned that case classes extend Product, I wondered why they do not extend ProductN. E.g., given a code like:

case class Foo(a: Int)

I

3条回答
  •  离开以前
    2021-02-19 09:37

    If Product1[Int] would have been automatically extended the val _1: Int would also have to be provided. Although I could imagine, that it could be automated that a gets assigned to _1 etc etc, but it is not. Probably just not to make things even more complicated.

提交回复
热议问题