Skip to content

Instantly share code, notes, and snippets.

@theapache64 theapache64/Main.kt
Created Feb 15, 2019

What would you like to do?
Delegation Pattern `by` Kotlin
interface Car {
fun carMethod();
interface Bus {
fun busMethod();
class Leyland : Bus {
override fun busMethod() {
println("Bus method")
class BMW : Car {
override fun carMethod() {
println("Car method")
class Combination(c: Car, b: Bus) : Car by c, Bus by b
fun main(args: Array<String>) {
val busPlusCar = Combination(BMW(), Leyland())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.