Why are case objects serializable and case classes not?

后端 未结 2 1894
半阙折子戏
半阙折子戏 2021-02-05 21:19

I am playing with this example http://scala.sygneca.com/code/remoteactors to learn how remote actors work in Scala (2.8.0). In particular I slightly modified how the messages se

相关标签:
2条回答
  • 2021-02-05 21:34
    @serializable case class Foo
    

    I was also surprised that case objects were serializable per default.

    Edit: After reading the exception properly I suspect that:

    You're trying to send the generated companion object of the case class over the wire, instead of an instance of the case class.

    0 讨论(0)
  • 2021-02-05 21:48

    Case classes without parameters are meaningless and deprecated. And I see no Serializable in Scala, just serializable. Does it work if you fix these things?

    0 讨论(0)
提交回复
热议问题