如果我在這裏更改Groovy DSL Doc中的代碼。如何使用@DelegatesTo註解將參數傳遞給閉包?
添加一些字符串「世界你好」,以電子郵件,這樣
email('hello world') { // change here
from '[email protected]'
to '[email protected]'
subject 'The pope has resigned!'
body {
p 'Really, the pope has resigned!'
}
}
,改變
def email(def name, @DelegatesTo(EmailSpec) Closure cl) { // change here
def email = new EmailSpec()
def code = cl.rehydrate(email, this, this)
code.resolveStrategy = Closure.DELEGATE_ONLY
code.call(name) // change here
}
那麼,如何修改類EmailSpec得到字符串'你好世界?