Avatar
omochimetaru 3/21/2017 3:25 AM
rubyのこれも近いけど、言語自体にinterfaceが無いせいでメソッド全部並べてるな・・・
3:26 AM
Kotlin is a statically typed programming language for the JVM, Android and the browser, 100% interoperable with Java
3:26 AM
あった!
3:26 AM
kotlinだ!
3:26 AM
interface Base { fun print() } class Derived(b: Base) : Base by b
3:27 AM
bはこれ、型名のところに書いてるけどコンストラクタ引数とフィールド定義を同時にやってるので、 bBase 型のフィールドで、 DerivedBase に conformさせるのを by b で指定してる。
3:28 AM
The by-clause in the supertype list for Derived indicates that b will be stored internally in objects of Derived and the compiler will generate all the methods of Base that forward to b.