class Test {
static function main() {
trace("First foo:" + ThingTypes.firstFoo);
trace("Bar 2:" + ThingTypes.bar2);
trace("Last bar:" + ThingTypes.lastBar);
}
}
@:enum abstract ThingTypes(String) from String to String {
var firstFoo = foo1;
var foo1 = "foo1";
var foo2 = "foo2";
var foo3 = "foo3";
var lastFoo = foo3;
var firstBar = bar1;
var bar1 = "bar1";
var bar2 = "bar2";
var bar3 = "bar3";
var lastBar = bar3;
}
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
getIndex (e:EnumValue):Int in http://api.haxe.org/haxe/EnumValueTools.htmlcreateByIndex<T> (e:Enum<T>, index:Int, ?params:Array<Dynamic>):T in http://api.haxe.org/haxe/EnumTools.htmlYou could change it to :
@:enum abstract ThingTypes(Int) from Int to Int {
var firstFoo = foo1;
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var lastFoo = foo3;
var firstBar = bar1;
var bar1 = 4;
var bar2 = 5;
var bar3 = 6;
var lastBar = bar3;
}
Not the most convenient but will do the trick. It also keeps the runtime code /performance pretty clean. See
http://haxe.org/manual/types-abstract-enum.html
▶ Show quoted text