Last active
April 21, 2016 05:51
-
-
Save kittinunf/733673ad1ea85b6088e4d3aa32af2519 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Fooable { | |
fun foo(): String | |
} | |
class FooImpl : Fooable { | |
override fun foo() = "I am fooImpl" | |
} | |
class AnotherFooImpl : Fooable { | |
override fun foo() = "I am anotherFooImpl" | |
} | |
class X(impl: Fooable) : Fooable by impl | |
fun main(args: Array<String>) { | |
val x = X(FooImpl()) | |
println(x.foo()) //print I am fooImpl | |
val y = X(AnotherFooImpl()) | |
println(y.foo()) //print I am anotherFooImpl | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment