직장에서 우리는 단순한 (또는 간단하지 않은) 질문에 대해 논의하고 있습니다. ¿ 다음 호출 메소드간에 차이점이 있습니까?클로저 컬렉션. 다른 호출 메소드.
class Obj {
def num
def prtn = {
print this.num
}
}
def listObj = [new Obj(num:1), new Obj(num:2), new Obj(num:3), new Obj(num:4)]
// End Common code
// Method #1
def lst = listObj.collect{ obj-> obj.prtn() }
// Method #2
def lst = listObj.collect{ obj-> { -> obj.prtn()} }.each{ it() }
// Common code