title: Groovy alternative of Java8's .map() stream operation
body: <p>What is Groovy's alternative for Java 8's <code>.map()</code>?</p>
  
  <p>Example:</p>
  
  <pre><code>List&lt;String&gt; codes = events
      .stream()
      .map(event -&gt; event.getCode())
      .collect(Collectors.toList());
  </code></pre>
  
  <p>I was trying to do </p>
  
  <pre><code>events.each { it; return it.getCode() }.collect() as String[]
  </code></pre>
  
  <p>but I am getting <code>List</code> of <code>String</code>s, but <code>toString()</code> representation instead of code</p>