Groovy: meaning of 'this' inside a closure

后端 未结 4 1920
臣服心动
臣服心动 2021-02-14 12:53

The following example is adapted from \'Groovy in Action\'

class Mother {

    Closure birth() {                            
        def closure = { caller ->         


        
4条回答
  •  情书的邮戳
    2021-02-14 13:43

    {
        def self = ({ owner })()
    }
    

    owner: the enclosing object (this or a surrounding Closure).

提交回复
热议问题