RE
03/21/2022, 11:55 AMStephan Schroeder
03/21/2022, 3:36 PMStephan Schroeder
03/21/2022, 3:45 PMfun main() {
val d1 = DoubleArray(2){it.toDouble()}
val d2 = DoubleArray(2){it.toDouble()}
println(d1==d2)
}
prints false
.
https://pl.kotl.in/4W5_kBvI_Stephan Schroeder
03/21/2022, 3:47 PMRob Elliot
03/21/2022, 3:48 PMArrays.equals
to compare them by their values.Stephan Schroeder
03/21/2022, 3:59 PM@JvmInline
value class DAWrapper(
val doubles: DoubleArray
) {
override fun equals(other: Any?): Boolean {
if(other !is DAWrapper) return false
return Arrays.equals(doubles, other.doubles)
}
}
and get the compile error Member with the name 'equals' is reserved for future releases
Stephan Schroeder
03/21/2022, 4:02 PMdata class DAWrapper(
val doubles: DoubleArray
) {
override fun equals(other: Any?) =
other is DAWrapper &&
Arrays.equals(doubles, other.doubles)
}
Klitos Kyriacou
03/21/2022, 4:11 PM