# Automatically generate equals & hashCode methods

**URL:** <https://discuss.kotlinlang.org/t/automatically-generate-equals-hashcode-methods/3779>\
**Category:** Language Design\
**Created:** [July 17, 2017, 5:06pm UTC](https://discuss.kotlinlang.org/t/automatically-generate-equals-hashcode-methods/3779 "2017-07-17T17:06:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zargor](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/zargor/32/3184_2.png) [@Zargor](https://discuss.kotlinlang.org/u/Zargor)\
**Post date:** [July 17, 2017, 5:06pm UTC](https://discuss.kotlinlang.org/t/automatically-generate-equals-hashcode-methods/3779/1 "2017-07-17T17:06:43Z")

</div>

Hello!  
I just saw that I should override the equal and hashCode method, when I’m using an array in a data class.

 ![](https://us1.discourse-cdn.com/flex019/uploads/kotlinlang/original/2X/a/afabb35f38c1ce64ab7667e40bb6b7a384840dfa.png)  
My suggestion is that this will be auto generated by the compiler, so it checks every value etc.

---

<div class="post-metadata">

**Author:** ![cretz](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@cretz](https://discuss.kotlinlang.org/u/cretz)\
**Post date:** [July 17, 2017, 10:06pm UTC](https://discuss.kotlinlang.org/t/automatically-generate-equals-hashcode-methods/3779/2 "2017-07-17T22:06:12Z")

</div>

Coming: [https://youtrack.jetbrains.com/issue/KT-15893](https://youtrack.jetbrains.com/issue/KT-15893). Granted I disagree w/ the original design. I would have preferred that the data class hashCode/equals did what was most ergonomic for arrays and others. The argument was that they need to use equals/hashCode on the java.lang.Object without checking whether it was an array at runtime, but I don’t think it applies on specific array types and for base Any types the problem of using arrays persists. Too late now though.
