Extend data class in Kotlin

后端 未结 8 2017
日久生厌
日久生厌 2020-11-28 04:31

Data classes seem to be the replacement to the old-fashioned POJOs in Java. It is quite expectable that these classes would allow for inheritance, but I can see no convenien

8条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 04:47

    You can inherit a data class from a non-data class. Inheriting a data class from another data class is not allowed because there is no way to make compiler-generated data class methods work consistently and intuitively in case of inheritance.

提交回复
热议问题