mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
22 lines
329 B
Kotlin
Vendored
22 lines
329 B
Kotlin
Vendored
// WITH_RUNTIME
|
|
|
|
fun test(list: List<String>) {
|
|
val result = mutableListOf<String>()
|
|
use1 { list.forEach { result.add(it) } }
|
|
}
|
|
|
|
inline fun <T> use1(f: () -> T): T {
|
|
return use2(f)
|
|
}
|
|
|
|
inline fun <T> use2(f: () -> T): T {
|
|
try {
|
|
return f()
|
|
}
|
|
catch (e: Exception) {
|
|
throw e
|
|
}
|
|
}
|
|
|
|
// 1 POP
|