logo
  • 教程列表
  • SO官方文档
  • 模式匹配
    • 结构匹配
    • 逆天
    • 枚举匹配
    • 数组匹配
    • 或模式
    • 提取
  1. StackOverflow 文档
  2. haxe 教程
  3. 模式匹配
  4. 逆天

逆天

Created: November-22, 2018

也可以用护罩进一步限制图案。这些是由 case ... if(condition):语法定义的。

var myArray = [7, 6];
var s = switch(myArray) {
    case [a, b] if (b > a):
        b + ">" +a;
    case [a, b]:
        b + "<=" +a;
    case _: "found something else";
}

参考

  • 卫兵,Haxe 手册
  • 枚举匹配
  • 结构匹配

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明