Hi,
I am getting an “Unrecognised pattern” error returned when I evaluate a string set as a public static inline var in a switch statement.
class StateId
{
public static inline var SAMPLE : String = "/sample/";
}
In another class I run a switch statement
switch("/sample/")
{
case StateId.SAMPLE:
// do something
}
I know that this is something that has changed in haxe 3.3.0 but not sure what to do?
Thanks.
I’m still on Haxe 3.2.1, there’s too many problems with the RC1 release of Haxe 3.3 for me
This is the unfortunate thing. HaxeFoundation folk don’t want to support 3.2.1 anymore because they’re busy with 3.3, but 3.3 is too rusty to use…classic legacy support dilemma, I guess.
Removing the inline and making the variable read only from outside the class solves the compile time error.
public static var SAMPLE (default,null):String = "/sample/";
mrcdk
August 19, 2016, 10:35pm
#5
Which haxe version are you using? it’s working correctly on 3.3.0-rc.1 http://try-haxe.mrcdk.com/#ABdf4
For these cases I’d recommend you to use an abstract enum
. You get static inline by default and some benefits of both enums and abstracts.
Thanks, that is a good idea.