haxe - Haxe 中的局部常量 - 可能
问题描述
我知道在 Haxe 中有关于类属性的常量问题。我的问题是:是否可以在函数内部定义常量?像:
function foo(){
const bar=7;
bar = 8; // should prevent compilation
}
也许像 var 之类var foo:ReadOnlyInt
的东西?
解决方案
你正在寻找final
.
function foo() {
final bar = 7;
bar = 8; // not allowed
}
推荐阅读
- ruby-on-rails - 在rails中调用方法
- c++ - 如果 char *name = "Emma",为什么 &name 与 &name[0] 不同?
- flutter - Flutter streamProvider 未更新
- flutter - 颤振剪贴板选项未显示在 TextInputField 中
- sql - SQL中的时间戳差异
- php - 尝试发送电子邮件时调用字符串上的成员函数 getRealPath()
- python - 如何使用 pytesseract 对黄色立方体内的数字进行 detech
- powershell - Copy-items powershell 中的模式是什么,长度值始终为 0?
- task - AWS Connect API - StartTaskContact 操作:InvalidRequestException:
- android - 在 Xamarin Forms 中获取设备音量