我知道Haxe 中有一个关于类属性的常量问题。我的问题是:是否可以在函数内部定义常量?喜欢:
function foo(){
const bar=7;
bar = 8; // should prevent compilation
}
Run Code Online (Sandbox Code Playgroud)
也许像 var 之类的var foo:ReadOnlyInt东西?
您正在寻找final.
function foo() {
final bar = 7;
bar = 8; // not allowed
}
Run Code Online (Sandbox Code Playgroud)
https://haxe.org/manual/expression-var.html
| 归档时间: |
|
| 查看次数: |
49 次 |
| 最近记录: |