Generalize run() scope function.

#KT-5235 Fixed
This commit is contained in:
Ilya Gorbunov
2015-06-01 22:58:02 +03:00
parent 21ee2c1cfd
commit 3e231f2e44
+6 -1
View File
@@ -11,7 +11,12 @@ public fun <A, B> A.to(that: B): Pair<A, B> = Pair(this, that)
/**
* Calls the specified function.
*/
public inline fun <T> run(f: () -> T): T = f()
public inline fun <R> run(f: () -> R): R = f()
/**
* Calls the specified function with this value as its receiver.
*/
public inline fun <T, R> T.run(f: T.() -> R): R = f()
/**
* Execute f with given receiver