【发布时间】:2018-07-18 04:53:54
【问题描述】:
在 Java 中,可以使用花括号来描述具有自己作用域的代码块:
void f() {
{
int x = 1
// do something with x
}
// x not visible here anymore
}
这是如何在 Kotlin 中完成的?
【问题讨论】:
-
同样适用于 Kotlin
-
@Moira 是其中声明的任何变量的范围
标签: kotlin