I know when using Groovy closures, I can change the delegate
on the closure so function calls made within the closure could be defined externally.
我能否在沙捞?
具体来说,如果你采用以下守则:
def configure():
build()
def wrap(function):
def build():
print build
function()
wrap(configure)
我喜欢印刷(只改动<代码>wrap()。
一些说明:
I don t want to pass functions into configure()
since there may be a large number of functions that can be called by configure()
.
我也不想在全球界定这些职能,因为再次可能有许多职能可以通过<代码>configure(<>configure(>),我不想污染全球名称空间。