From 3e231f2e44cc95cc653a655b0d9510ccaa394834 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Mon, 1 Jun 2015 22:58:02 +0300 Subject: [PATCH] Generalize run() scope function. #KT-5235 Fixed --- libraries/stdlib/src/kotlin/util/Standard.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/stdlib/src/kotlin/util/Standard.kt b/libraries/stdlib/src/kotlin/util/Standard.kt index 7409886605a..aaf246af0a2 100644 --- a/libraries/stdlib/src/kotlin/util/Standard.kt +++ b/libraries/stdlib/src/kotlin/util/Standard.kt @@ -11,7 +11,12 @@ public fun A.to(that: B): Pair = Pair(this, that) /** * Calls the specified function. */ -public inline fun run(f: () -> T): T = f() +public inline fun run(f: () -> R): R = f() + +/** + * Calls the specified function with this value as its receiver. + */ +public inline fun T.run(f: T.() -> R): R = f() /** * Execute f with given receiver