hi everyone! pretty noob question here, I come fro...
# getting-started
m
hi everyone! pretty noob question here, I come from a Go background and I'm looking for something like composition in Kotlin, I know there's inheritance in the way that I can define a class like
Copy code
class Person(val name: String, val lastName: String)
class Employee(val name: String, val lastName: String): Person(name, lastName)
but is there a way to have that Employee class just inherit all the properties of Customer, without listing them all explicitly as properties ? my guess is no, but I may be missing something
j
Best what I've found is introducing interface with properties (getters) and using "by" keyword
interface Person(val name: String)
class Employee(private val person: Person): Person by person
j
Perhaps something like interfaces with default implementations, basically becoming mixins? https://kotlinlang.org/docs/reference/interfaces.html#properties-in-interfaces I'm also new so I haven't explored this much yet.