我有一些这样的代码
def lookupTickets() {
User currentUser = webAuthService.currentUser()
def http = new HTTPBuilder(zdURL)
http.auth.basic("${zdUser}/token", zdApiKey)
http.get(path: "/api/v2/users/search.json",
query: [query: currentUser.emailAddress],
requestContentType: ContentType.JSON, { resp, json ->
println "Response status: ${resp.statusLine}"
def zenDeskUserId = json?.users[0]?.id
})
return MYRESULT
}
该行def zenDeskUserId = json?.users[0]?.id
给了我想要返回浏览器的结果。
当它仅在内部闭包内的范围内时,如何在外部方法中返回此值?