title: How to pipe the result of a transformation chain to a function?
body: <p>I want to write a chain of transformations and finally have a block where I do something with the resulting collection, without using variables.
  Is there a higher-order function on collections that just provides the collection on which it is called to the supplied function?</p>
  
  <pre><code>Query( ... )
    .map { ... }
    .filter { ... }
    .combinations(2)
    .pipeTo { col =&gt;
       ...
       consolidate(col)
    }
  </code></pre>
  
  <p>Of course for a single function call one could do it like this:</p>
  
  <pre><code>consolidate(
    Query()
      .map { ... }
      .filter { ... }
      .combinations(2)
  )
  </code></pre>
  
  <p>But the former reads more natural to me and allows e.g. for an easy injection of some conditionals.</p>
  
  <p>A workaround I've been using is placing a match clause at the end:</p>
  
  <pre><code>Query()
    .map { ... }
    .filter { ... }
    .combinations(2)
    match { case lst =&gt;
      ...
      consolidate(lst)
    }
  </code></pre>
  
  <p>But since this pattern occurs quite often I was wondering what is the idiomatic way to write this.</p>