Kotlin has a data class like
@Entity data class Record( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val id: Long? = null, @Column(nullable = false, name = "name") var name: String? = null )
And I can call the component1 and component2 functions to access the properties. However, when I declare a var property, I have a getter and setter, and if I declare a val property, I have a getter. In this case, the Component functions are redundant and why do we need them because the getters seem much more understandable?
source share