January 2018
Intermediate to advanced
434 pages
14h 1m
English
What happens when you create an extension function with a name similar to that of a member function? For example, in the following code, what will happen if we call c.foo()?:
fun main(args: Array<String>) { var c= C() c.foo()}class C{ fun foo(){ println("from member") }}private fun C.foo() { println("from extension")}
This is the output we get:
from member
So a member function will win if an extension function with the same name is called.
Read now
Unlock full access