title: Chain (compose) method calls in Groovy
body: <p>I have a variable and several methods I'd like to call in a sequence where return value of one method is an input of another. Basically a pipeline. Now, is there a way of chaining the calls? In a pseudo code it looks like</p>
  
  <pre><code>def a = [1, 2, 3]
  def b = calculation3(calculation2(calculation1(a)))
  </code></pre>
  
  <p>As you can see it looks very Clojure-like and I'd like to end up with something like (using Clojure syntax) </p>
  
  <pre><code>(-&gt; a 
     calculation1
     calculation2
     calculation3)
  </code></pre>
  
  <p>I was hoping to use the <code>with</code> keyword but it only passes the variable <code>a</code> around not collecting the results and passing them as the input to the next method. </p>
  
  <p>The only working solution I've found so far is 'closure composition' like this. But that seems to be too heavy handed to me.</p>
  
  <pre><code>def a = [1, 2, 3]
  def b = (class1.&amp;calculation1 &gt;&gt; class1.&amp;calculation2 &gt;&gt; class1.&amp;calculation3)(a)
  </code></pre>
  
  <p>Any idea?</p>