お世話様です。現在Kotlinを学習中なのですが、
Kotlin1.2において
以下のようなクラス及び拡張メソッドが存在したとします。
class Some{ fun print()= println("member method") } fun Some.print()=println("extended method")
このような場合、Extensions are resolved staticallyの後半部分に、
If a class has a member function, and an extension function is defined which has the same receiver type, the same name and is applicable to given arguments, the member always wins.
と有りますので、以下のようなコードを書いた場合、
fun main(args:Array<String>){ val s=Some() s.print() }
当然、メンバメソッドの方が呼ばれます。
ここで質問なのですが、このようなシナリオに於いて、拡張メソッド側を明示的に呼び出すことは可能でしょうか?
以上ご教授の程よろしく御願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。