Join Slack
Powered by
Isn't there more simple way to achieve something l...
# announcements
j
Jukka Siivonen
03/19/2019, 1:24 PM
Isn't there more simple way to achieve something like this, that is to "compose a type from other types" without inheritance?
https://proandroiddev.com/kotlin-composition-and-delegation-d1a387f8c158
Jukka Siivonen
03/19/2019, 2:24 PM
Ended up experimenting like this:
Copy code
data class Foo(private val bar: Bar): BarFields by bar
Jukka Siivonen
03/19/2019, 2:25 PM
downside is you still need to define interface BarFields which adds some duplication when you have lot of fields
d
David Cuesta
03/19/2019, 4:23 PM
That is the most common way of doing it as far as I know
2
Views
Open in Slack
Previous
Next