Quick question.. I am new to Kotlin and I am wonde...
# announcements
d
Quick question.. I am new to Kotlin and I am wondering can anyone tell me the use of the componentN function in data classes? For example
data class Person(val firstName: String ="Demetrious", val lastName:String = "Robinson")
val person1 = Person()
println(person1.component1()) // "Demetrious"
I don't see the use of that as it only returns the value and not the property name. Wouldn't it be simpler to just write
println(person1.firstName)
c
d
Oh okay. Makes sense. thank you @Casey Brooks
l
I suppose they can also be used for any tools that might scan classes for reflection