Junior
What are the requirements when creating a data class in Kotlin?
sobes.tech AI
Answer from AI
- The primary constructor must have at least one parameter marked with
valorvar. - The class cannot be
abstract,open,sealed, orinner. - The class cannot inherit from other classes.
- The class can implement interfaces.
The compiler automatically generates the following functions for data classes:
equals()hashCode()toString()componentN()(for destructuring)copy()