我有下面的代碼:哪個迭代arrayList直到結束,即使我不需要它。由於xtend沒有break語句,我不知道如何分解它。假如我不能將它轉換爲while循環,xtend中有沒有其他方法類似於java中的break語句?如何打破xtend中的foreach循環?
arrayList.forEach [ listElement | if (statusFlag){
if(monitor.canceled){
statusFlag = Status.CANCEL_STATUS
return
}
else{
//do some stuff with listElement
}
}]
不錯,比使用異常更簡潔! –