by hota_mazi · 8y ago · 0 comments
I can use composition and inheritance to define an IS_A relationship and I can use them to define a HAS_A relationship.
For example, in Kotlin:
class A : B // IS_A via inheritance
class A(b: B) { // HAS_A via composition
class A(b: B) : B by b // IS_A via compositionI couldn't find the "B by b" syntax from the Kotlin docs, can you tell me that this does ?
Look at page 96 of this PDF file: https://kotlinlang.org/docs/kotlin-docs.pdf