Difference between case object and object

后端 未结 7 518
梦如初夏
梦如初夏 2020-12-02 04:36

Is there any difference between case object and object in scala?

7条回答
  •  感动是毒
    2020-12-02 04:55

    case objects implicitly come with implementations of methods toString, equals, and hashCode, but simple objects don't. case objects can be serialized while simple objects cannot, which makes case objects very useful as messages with Akka-Remote. Adding the case keyword before object keyword makes the object serializable.

提交回复
热议问题