1
我在常規下陣的枚舉值:比較Groovy的陣列
test = [Andrew-PAR, Jackson-CDG, Jilly-MAD, Mike-CDG, Tim-AGP]
而且也是繼枚舉
NAME_PLACE("Andrew-PAR, Jackson-CDG, Brian-NY")
獲取枚舉值像Andrew-PAR, Jackson-CDG, Brian-NY
我需要的是 *有找出不在數組'test' 中的值,即輸出將是'Brian-NY'
我試圖<enum returned values> - test
找到輸出 - 但它顯示了枚舉像Andrew-PAR, Jackson-CDG, Brian-NY
代碼枚舉整個價值:
public enum StudentDetails {
NAME_PLACE("Andrew-PAR, Jackson-CDG, Brian-NY"),
NAME_COURSE("TEST1, TEST2"),
private final String studentdetails
StudentDetails (String studentdetails) {
this.studentdetails = studentdetails
}
public String getstudent() {
return studentdetails
}
}
代碼獲取枚舉值:
def student = StudentDetails.values().find {
val.equalsIgnoreCase(it.name())
} ?.getstudent()
尋找差異:
def diff = student - test
它沒有爲我工作。看起來像枚舉不返回任何數組 – Futuregeek
好吧,我編輯了我的代碼 – chf