我是 groovy 的新手。我试图弄清楚基本语法。以下代码片段:
def CRITICAL = 2;
def MAJOR = 3;
def MINOR = 9;
def GetPriorityFromString(String priorityStr) {
switch (priorityStr){
case "Critical" : return CRITICAL;
case "Major" : return MAJOR;
case "Minor" : return MINOR;
}
return 0;
}
GetPriorityFromString("Minor")
导致此错误:
groovy.lang.MissingPropertyException: No such property: MINOR for class: Script21
我做错了什么?
(而且由于我是这种语言的新手,请随意提出任何“groovier”方法来将字符串转换为枚举值。)