title: Groovy filtering array with findAll method
body: <p>I am learning Groovy and I am trying to write an alternative to the following bit of Java code. </p>
  
  <pre><code>Collection&lt;Record&gt; records = requestHelper.getUnmatchedRecords();
  Collection&lt;Integer&gt; recordIdentifiers = new ArrayList&lt;&gt;();
  for (Record record : records){
      int rowId = record.getValue("RowID");
      if (rowId &gt;= min &amp;&amp; rowId &lt;= max) {
          recordIdentifiers.add(rowId);
      }
  }
  </code></pre>
  
  <p>When that bit of code is run recordIdentifiers should contain 50 items. This is my Groovy equivalent so far.</p>
  
  <pre><code>def records = requestHelper.getUnmatchedRecords()
  def recordIdentifiers = records.findAll{record -&gt;
      int rowId = record.getValue("RowId")
      rowId &gt;= min &amp;&amp; rowId &lt;= max
  }
  </code></pre>
  
  <p>For some reason the array contains 100 items after Groovy code is executed. All the examples of findAll() I have come across do simple comparisons when the array is constructed natively in Groovy, but how do you filter a Collection that you receive from a Java class? </p>