karelpeeters
01/07/2019, 7:12 PMhashcode()
? Can you give an example?liminal
01/07/2019, 7:14 PMhashCode()
or javaClass.hashCode()
. the latter is always the same and is based off an interface looks likekarelpeeters
01/07/2019, 7:18 PMinterface Foo {
fun printHashcode() { println("Hash: ${hashCode()}") }
}
class Bar: Foo
fun main() {
val bar = Bar()
bar.printHashcode()
}
liminal
01/07/2019, 7:26 PMkarelpeeters
01/07/2019, 7:29 PMhashCode
function generated by the data class probably just returns itemId.hashCode()
and maybe that happens to be 1
for the string you're using?liminal
01/07/2019, 7:31 PMkarelpeeters
01/07/2019, 7:33 PMliminal
01/07/2019, 7:34 PMkarelpeeters
01/07/2019, 7:36 PMliminal
01/07/2019, 7:40 PMkarelpeeters
01/07/2019, 7:42 PMitemId
is an Int
, not a String
. The automatically generated hashcode
implementation just returns that int as the hashcode.liminal
01/07/2019, 7:48 PMkarelpeeters
01/07/2019, 7:52 PM