Slide 24
Slide 24 text
Copyright © Sansan, Inc. All rights reserved.
> 元のクラスが継承されている場合
open class ParentClass
class ChildClass: ParentClass()
fun ParentClass.greeting() = println("hello!")
fun ChildClass.greeting() = println(“good bye!”)
fun printGreeting(obj: ParentClass) {
obj.greeting()
}
printGreeting(ChildClass())
>> hello!