Groovy 不要求 switch 表达式必须详尽。 它的作用就像插入了隐式 default -> null 分支。 如果开发者忘记插入必要的 case 分支,可能会导致意外的 null。
default -> null
case
示例:
enum A { X, Y } def foo(A a) { def x = switch (a) { // reports switch case A.X -> ... } }