equals() 또는 hashCode()가 재정의되지 않은 data 클래스의 Array 타입이 있는 프로퍼티를 보고합니다.

배열 매개변수가 참조 상등과 비교되며 이는 예상하지 못한 동작일 수 있습니다. 그러한 경우 equals()hashCode()를 재정의하는 것이 좋습니다.

예:


  data class Text(val lines: Array<String>)

빠른 수정에서는 누락된 equals()hashCode() 구현을 생성합니다.


  data class Text(val lines: Array<String>) {
      override fun equals(other: Any?): Boolean {
          if (this === other) return true
          if (javaClass != other?.javaClass) return false

          other as Text

          if (!lines.contentEquals(other.lines)) return false

          return true
      }

      override fun hashCode(): Int {
          return lines.contentHashCode()
      }
  }