You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not qualified to describe all the semantics, but the goal is that const variables can not be re-assigned, which (I assume) would correspond to Java final or ECMAScript const. A const Array or object would not be immutable.
Haxe being openly inspired by ECMAScript it wouldn't hurt to follow what people are now used in ES6/TypeScript, that is using const.
classFoo{consta:Int;// must be initialised in ctor, then is finalconstb='a const';// variable is final and can be inlinedstaticconstc='also const';// equivalent to 'static inline var'functionnew(){a=42;a=-1;// compiler error, already assignedconstd=123;d=0;// compiler errorconste=[];e=['no'];// compiler errore.push('yes');// ok, only the Array reference is final}}
The text was updated successfully, but these errors were encountered:
We need a way to declare non mutable variables.
I'm not qualified to describe all the semantics, but the goal is that
const
variables can not be re-assigned, which (I assume) would correspond to Javafinal
or ECMAScriptconst
. Aconst
Array or object would not be immutable.Haxe being openly inspired by ECMAScript it wouldn't hurt to follow what people are now used in ES6/TypeScript, that is using
const
.The text was updated successfully, but these errors were encountered: