What about a function `inline fun <T> __appl...
# stdlib
l
What about a function
inline fun <T> __apply(receiver: T, block: T.() -> Unit): T
(name tbd) which behaves excactly like the current`apply`. Reasoning: When using Java libraries I tend to avoid extension functions with "simple" names (such as
apply
,
run
,
let
, etc.) since it is always possible that a method with the same name is added to a class in a Java library. Due to Kotlin's resolution rules this could easily result in a source-incompatible change (depending on the exact method signature). However, with
__apply(object)
this would not be a problem. Additionally, there is already a similar pattern in the stdlib:
with
and
run
. (See also https://kotlinlang.org/docs/reference/scope-functions.html#function-selection) Bonus "real-world example": https://github.com/LWJGL/lwjgl3/issues/554
d
I think it would be simple enough for you to create your own extension function that aliases to
apply
when you really need it.