nested_match.gd 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. 1234:
  12. print("3")
  13. continue
  14. _:
  15. print("Should also be printed")
  16. match number:
  17. 1234:
  18. print("4")
  19. match number:
  20. _:
  21. print("5")
  22. match number:
  23. false:
  24. print("Should not be printed")
  25. true:
  26. print("Should not be printed")
  27. "hello":
  28. print("Should not be printed")
  29. 1234:
  30. print("6")
  31. match number:
  32. _:
  33. print("7")
  34. match number:
  35. 1234:
  36. print("8")
  37. match number:
  38. _:
  39. print("9")
  40. match number:
  41. 1234:
  42. print("10")
  43. match number:
  44. _:
  45. print("11")
  46. match number:
  47. 1234:
  48. print("12")
  49. match number:
  50. _:
  51. print("13")
  52. match number:
  53. 1234:
  54. print("14")
  55. match number:
  56. _:
  57. print("15")
  58. match number:
  59. _:
  60. print("16")
  61. match number:
  62. 1234:
  63. print("17")
  64. match number:
  65. _:
  66. print("18")
  67. match number:
  68. 1234:
  69. print("19")
  70. match number:
  71. _:
  72. print("20")
  73. match number:
  74. []:
  75. print("Should not be printed")
  76. _:
  77. print("Should not be printed")
  78. 5678:
  79. print("Should not be printed either")