# More compact equals?

**URL:** <https://discuss.kotlinlang.org/t/more-compact-equals/18276>\
**Category:** Uncategorized\
**Created:** [June 30, 2020, 10:02am UTC](https://discuss.kotlinlang.org/t/more-compact-equals/18276 "2020-06-30T10:02:52Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![andrewww](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/andrewww/32/2686_2.png) [@andrewww](https://discuss.kotlinlang.org/u/andrewww)\
**Post date:** [June 30, 2020, 10:02am UTC](https://discuss.kotlinlang.org/t/more-compact-equals/18276/1 "2020-06-30T10:02:52Z")

</div>

Now android studio generates method equals as below:

```
class Current(val id: Long) {
    
       override fun equals(other: Any?): Boolean {
               if (this === other) return true
               if (javaClass != other?.javaClass) return false

               other as Current

              if (id != other.id) return false

             return true
     }
}

```

I often rewrite it to:

```
class Compact(val id: Long) {

      override fun equals(other: Any?): Boolean {
             return other is Compact && id == other.id
      } 
}

```

Does my variant has some whitespaces? Is current variant generated by ide too verbose?

---

_[View the full topic](https://discuss.kotlinlang.org/t/more-compact-equals/18276)._
