diff --git a/libraries/stdlib/src/kotlin/util/Standard.kt b/libraries/stdlib/src/kotlin/util/Standard.kt index 477b46c149b..6155ff3407d 100644 --- a/libraries/stdlib/src/kotlin/util/Standard.kt +++ b/libraries/stdlib/src/kotlin/util/Standard.kt @@ -9,23 +9,26 @@ package kotlin public fun A.to(that: B): Pair = Pair(this, that) /** - * Calls the specified function. + * Calls the specified function [f] and returns its result. */ public inline fun run(f: () -> R): R = f() /** - * Calls the specified function with this value as its receiver. + * Calls the specified function [f] with `this` value as its receiver and returns its result. */ public inline fun T.run(f: T.() -> R): R = f() /** - * Execute f with given receiver + * Calls the specified function [f] with the given [receiver] as its receiver and returns its result. */ public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() +/** + * Calls the specified function [f] with `this` value as its receiver and returns `this` value. + */ public inline fun T.apply(f: T.() -> Unit): T { f(); return this } /** - * Converts receiver to body parameter + * Calls the specified function [f] with `this` value as its argument and returns its result. */ public inline fun T.let(f: (T) -> R): R = f(this)