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

  • 關於本站
  • 免責聲明