0
從the documentation, 13.5.5:把封閉
當一個方法的最後一個參數是一個閉包,你可以在方法調用
好後放置 關閉,我試過了,但它沒我確實按我的設想工作。請看下面的代碼:
def repostiory_closure = {
mavenCentral()
}
repositories{ //OK
mavenCentral()
}
repositories(){ //OK
mavenCentral()
}
repositories repostiory_closure //OK
repositories() repostiory_closure //compile-time error
所以我們可以把只有封閉文字一個方法調用之後,但Closure
類型的變量。是對的嗎?