groovy闭包的创建和调用

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

class A {
    private int member = 20;

    private method()
    {
      println ("hello");
    }

    def publicMethod (String name_)
    {
      def localVar = member + 5
      def localVar2 = "Parameter: name_";
      return {
        println "${member} ${name_} ${localVar} ${localVar2} ${method()}"
      }
    }
  }

  A anA = new A();
  closureVar = anA.publicMethod("Xavier");
  closureVar();
  closureVar2 = anA.publicMethod("Xavier");
  closureVar2();