I came across with kotlin equals function to compare two list of same type. It works fine for pure Kotlin with data classes.
I'am using a Java library in Kotlin project in which a callback method returns a list of objects for a time interval of X seconds. Trying to compare the old list with new list for every call, but equals returns false even the items are same and equal.
val mOldList: MutableList<MyObject>()? = null
override fun updatedList(list: MutableList<MyObject>){
// other code
if (mOldList.equals(list)) // false everytime
}
Is this because of Java's equals method from library?
Alternative suggestions for list compare would be appreciative.
ArrayList
vsLinkedList
. – KandykaneMyObject
override theequals()
method? – Baumgardnerequals()
method is override'd in library. – Hexastichequals()
. – Baumgardner