Trying to understand distinct() and distinctBy function to check duplicates. when i try "distinct" with list of strings, it works fine. when i try it with Type "Any" with custom class NO luck :( can anyone please help me understand?
var a = ArrayList<Any>()
val terry = Person("Terry",13)
val joe = Person("Joe", 20)
val sam1 = Person("Sam",33 )
a.add(terry)
a.add(joe)
a.add(sam1)
var b = ArrayList<Any>()
val valdi = Person("Valdi",55)
val tak = Person("Tak", 54)
val sam2 = Person("Sam",33 )
b.add(valdi)
b.add(tak)
b.add(sam2)
a.addAll(b)
val c = a.distinct()
println(c) //prints all 6 items. sam1 and sam2 is duplicated.