title: Are there any advantage for passing closure to a method?
body: <p>I wonder what is the real use of passing a closure object to a method. </p>
  
  <p>Lets say I have a closure : </p>
  
  <pre><code>def a = {
          println it
   }
  </code></pre>
  
  <p>(Consider it is doing some sort of operation rather than just printing)</p>
  
  <p>Now I'm just passing this closure <code>a</code> to a method :</p>
  
  <pre><code>def testMethod(def input,Closure a){
          a(input)
  }
  
  testMethod "MethodPointer", a //passing closure.
  </code></pre>
  
  <p>Now the question is why this level of <em>indirection</em>? Why can't <code>testMethod</code> directly process  its <code>input</code>? Yes, here I'm making <code>input</code> to be processed in closure <code>a</code>, but why one should do so?. What is the real use of passing closure around?</p>
  
  <p>Thanks in advance. </p>