1

I have a problem with my haxe code, So I have the following code :

var t : String = switch( id ) {
        case 1 : Std.random( 2 ) == 0 ? Texts.list.0 : Texts.list.1;
        case 2 : Std.random( 2 ) == 0 ? Texts.list.2 : Texts.list.3;
        default: "";
    }

For the default I get an error : This pattern is unused. Can you help me please? Thx in advance

TanGio
  • 766
  • 2
  • 12
  • 34

1 Answers1

2

This is due that compiler detects patterns which will never match the input value http://haxe.org/manual/lf-pattern-matching-unused.html

In this case it might be bug https://github.com/HaxeFoundation/haxe/issues/4387 if You use haxe 3.2, try 3.1.3 to ensure.

In try.haxe your sample works well http://try.haxe.org/#9e54A

Andrew
  • 1,282
  • 6
  • 11