Why does `Array(0,1,2) == Array(0,1,2)` not return the expected result?

后端 未结 3 1182
再見小時候
再見小時候 2020-11-30 05:33

As far as I understand, Scala\'s == defines the natural equality of two objects.

I expected that Array(0,1,2) == Array(0,1,2) compares the

3条回答
  •  生来不讨喜
    2020-11-30 06:23

    Scala doesn't override Array's equality because it's not possible. One can only override methods when subclassing. Since Array isn't being subclassed (which isn't possible), Scala cannot override its methods.

提交回复
热议问题