I want to pass a parameter to a function (actually...
# getting-started
k
I want to pass a parameter to a function (actually a super class constructor call), and this parameter is a complicated expression and I tried using
run { ... }
. However,
run
is overloaded as both an extension and non-extension function. Since the context includes an implicit "this" receiver, Kotlin favours calling the extension version. How can I force it to run the non-extension version?
Found the answer: call
kotlin.run
instead of just
run
.
e
Kotlin should always prefer calling a member function. what do you mean by "non-extension function"?
r
@ephemient In this case "non-extension" means it doesn't have a receiver, not that it isn't a member. https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/run.html