title: Groovy : how to pass closure as parameter to execute the methods inside the class
body: <p>I need to pass a list of methods to execute inside the class with "closure way", see the code bellow</p>
  
  <pre><code> class A{
      def m1(){
        println "Method1"
      }
  
      def m2(){
        println "Method1"
      }
  
     def commands = { closure-&gt;
        println "before"
        closure.call()
        println "after"    
     }
  
  }
  
  
  A a = new A()
  a.commands{
     println "before execute method m1"
     m1() //A need to execute m1 method of the class A
     println "after execute method m1"
  }
  </code></pre>
  
  <p>When I comment the <code>m1()</code> the output is </p>
  
  <pre><code>  before
    before execute method m1
    after execute method m1
    after
  </code></pre>
  
  <p>otherwise throw the exception <code>MissingMethodException: No signature of method for method m1()</code></p>
  
  <p>So, it does not recognize the <code>m1()</code> method as method of <code>class A</code></p>