0

I have data class ItemMainData(val title: String?, val fields: Array<Field>). What's the proper way to override hashCode()?

I am aware of this answer (Equals method for data class in kotlin), but in that case the hash of the array is sufficient to be the hash of the data class. It's not so in my case

4

1 回答 1

1

如果您在 IDE 中按“生成”并从菜单中选择“equals() 和 hashCode()”,它将为您生成正确的实现。实现将使用该Arrays.hashCode()方法生成数组的哈希码。

于 2018-06-14T15:56:04.437 回答