小编Dav*_*ulo的帖子

是否有可能在groovy中获取闭包的调用者对象?

是否有可能获得在执行上下文Object中调用a 的引用?ClosureClosure

例如:

public class Example {

    public Example(){
        def a = {return this};
        def b = [];

        b.metaClass.a = a;

        println b.a();
    }
}
Run Code Online (Sandbox Code Playgroud)

我希望这个执行返回b而不是实例Example.

groovy closures

9
推荐指数
1
解决办法
1551
查看次数

标签 统计

closures ×1

groovy ×1