Unify documentation for scope functions.

This commit is contained in:
Ilya Gorbunov
2015-07-17 17:52:18 +03:00
parent 8a578a46f6
commit 1857725629
+7 -4
View File
@@ -9,23 +9,26 @@ package kotlin
public fun <A, B> A.to(that: B): Pair<A, B> = Pair(this, that)
/**
* Calls the specified function.
* Calls the specified function [f] and returns its result.
*/
public inline fun <R> 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, R> 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 <T, R> 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> 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, R> T.let(f: (T) -> R): R = f(this)