Equality in Kotlin

前端 未结 3 995
陌清茗
陌清茗 2020-12-11 00:28

I\'m learning Kotlin, with a C++ and Java background. I was expecting the following to print true, not false. I know that == maps to <

3条回答
  •  失恋的感觉
    2020-12-11 01:08

    The default equals implementation you're describing exists only for data classes. Not for regular classes where the implementation is inherited from Any, and just make the object equal to itself.

提交回复
热议问题