title: Guava - How to apply a function that returns Void on an Iterable
body: <p>I just wonder what's the best way to apply a function that returns <code>Void</code> on an <code>Iterable/Collection</code>?</p>
  
  <p>My usecase is: </p>
  
  <ul>
  <li>i have a list of <code>Animal</code> objects</li>
  <li>i want to call on each animal of the list the <code>eat()</code> function</li>
  </ul>
  
  <p>I have a <code>Function&lt;Animal,Void&gt;</code> which calls <code>input.eat();</code></p>
  
  <p>It turns out that when i call:</p>
  
  <pre><code>Collections2.transform(animalList,eatFunction);
  </code></pre>
  
  <p>I dont find this very elegant since i'm not looking for a transformation, but only for an application without any output.
  Worst, it does not even work since the Guava transformations are returning views.</p>
  
  <p>What works fine is:</p>
  
  <pre><code>Lists.newArrayList( Collections2.transform(animalList,eatFunction) );
  </code></pre>
  
  <p>But it's not elegant.
  What is the best way to apply a Void function to an Iterable/Collection, in a functional way with Guava?</p>
  
  <p><strong>Edit</strong>: </p>
  
  <ul>
  <li>Related question: <a href="https://stackoverflow.com/questions/14702380/inverse-of-suppliert-in-guava">Inverse of Supplier&lt;T&gt; in Guava</a></li>
  <li>Also as Dzik points out, if you are using Java8 instead of Guava there's the Consumer class: <a href="https://stackoverflow.com/a/32222080/82609">https://stackoverflow.com/a/32222080/82609</a></li>
  </ul>