Avoid using Array in the data class constructor in Kotlin | by Anatolii Frolov | Apr, 2025
Now, let’s modify the example slightly by changing the friends property to use an Array instead of a List: data class Person(val name: String,val friends: Array)fun main() {val person1 = Person(name = “Mike”,friends = arrayOf(“Mary”, “John”, “Tom”))val person2 = Person(name = “Mike”,friends = arrayOf(“Mary”, “John”, “Tom”))println(person1 == person2)} Output: false Even though both Person instances … Read more