nested_match.gd 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. func test():
  2. # 20 levels of nesting (and then some).
  3. var number = 1234
  4. match number:
  5. 1234:
  6. print("1")
  7. match number:
  8. 1234:
  9. print("2")
  10. match number:
  11. 4321:
  12. print("Should not be printed")
  13. _:
  14. print("3")
  15. match number:
  16. 1234:
  17. print("4")
  18. match number:
  19. _:
  20. print("5")
  21. match number:
  22. false:
  23. print("Should not be printed")
  24. true:
  25. print("Should not be printed")
  26. "hello":
  27. print("Should not be printed")
  28. 1234:
  29. print("6")
  30. match number:
  31. _:
  32. print("7")
  33. match number:
  34. 1234:
  35. print("8")
  36. match number:
  37. _:
  38. print("9")
  39. match number:
  40. 1234:
  41. print("10")
  42. match number:
  43. _:
  44. print("11")
  45. match number:
  46. 1234:
  47. print("12")
  48. match number:
  49. _:
  50. print("13")
  51. match number:
  52. 1234:
  53. print("14")
  54. match number:
  55. _:
  56. print("15")
  57. match number:
  58. _:
  59. print("16")
  60. match number:
  61. 1234:
  62. print("17")
  63. match number:
  64. _:
  65. print("18")
  66. match number:
  67. 1234:
  68. print("19")
  69. match number:
  70. _:
  71. print("20")
  72. match number:
  73. []:
  74. print("Should not be printed")
  75. _:
  76. print("Should not be printed")
  77. 5678:
  78. print("Should not be printed either")