From 18577256290ed136f4499db11ab9534213947501 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 17 Jul 2015 17:52:18 +0300 Subject: [PATCH] Unify documentation for scope functions. --- libraries/stdlib/src/kotlin/util/Standard.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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)