[英]Local constants in Haxe - possible
I know there is this question Constants in Haxe about class properties.我知道Haxe 中有一个关于 class 属性的问题常量。 My question is: is it possible to define constants inside functions?
我的问题是:是否可以在函数内部定义常量? Like:
喜欢:
function foo(){
const bar=7;
bar = 8; // should prevent compilation
}
Maybe anything like var var foo:ReadOnlyInt
or something?也许像 var
var foo:ReadOnlyInt
类的东西?
You're looking for final
.您正在寻找
final
的 .
function foo() {
final bar = 7;
bar = 8; // not allowed
}
https://haxe.org/manual/expression-var.html https://haxe.org/manual/expression-var.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.