【问题标题】:Switch-case in haxehaxe 中的开关盒
【发布时间】:2015-10-27 22:50:29
【问题描述】:

我的haxe代码有问题,所以我有以下代码:

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: "";
    }

对于默认值,我得到一个错误:This pattern is unused。 你能帮我吗?提前谢谢

【问题讨论】:

    标签: haxe haxelib


    【解决方案1】:

    这是因为编译器检测到的模式永远不会匹配输入值http://haxe.org/manual/lf-pattern-matching-unused.html

    在这种情况下,它可能是错误https://github.com/HaxeFoundation/haxe/issues/4387 如果您使用haxe 3.2,请尝试3.1.3以确保。

    在 try.haxe 中,您的示例运行良好 http://try.haxe.org/#9e54A

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-14
      • 1970-01-01
      • 2017-02-08
      • 2017-07-25
      相关资源
      最近更新 更多