Ruckus
11/12/2019, 2:49 PMinline infix fun Any?.hash(other: Any?): Int = hashCode() * 31 + other.hashCode()
It would simplify writing hashCode
functions:
class ABC<A, B, C>(val a: A, val b: B, val c: C) {
override fun hashCode() = a hash b hash c
}
Ruckus
11/12/2019, 3:06 PMBurkhard
11/12/2019, 3:08 PMhashCode
functions I use are from data classes. Also with a good IDE you will just auto generate the hashCode
function in any case.Ruckus
11/12/2019, 3:14 PMspand
11/12/2019, 3:22 PMObjects.hash
?karelpeeters
11/12/2019, 3:24 PMspand
11/12/2019, 3:30 PMspand
11/12/2019, 3:32 PMhash
with agressive compiler inline and unroll than another Any?
extension. Just my two cents. Would be shorter to write alsospand
11/12/2019, 3:35 PMRuckus
11/12/2019, 3:36 PMspand
11/12/2019, 3:39 PMZach Klippenstein (he/him) [MOD]
11/21/2019, 6:18 PMBurkhard
11/22/2019, 6:02 AMcopy
function by providing a custom copy function that calls the generated one, you just need to annotate it with @Deprecated("", level = DeprecationLevel.HIDDEN)
. I don’t know a workaround for componentN
except for only adding new properties to the end. That said, I don’t like the fact that kotlin adds componentN
functions to all data classes automatically. Since they aren’t named, they just pose to much of a risk IMO. Especially when the data class is provided by a library.