code: public static <S,T> Collection<T> collect(Iterable<S> self, Collection<T> collector, @ClosureParams(FirstParam.FirstGenericType.class) Closure<? extends T> transform) {
          for (S item : self) {
              collector.add(transform.call(item));
              if (transform.getDirective() == Closure.DONE) {
                  break;
              }
          }
          return collector;
      }
docs: Iterates through this collection transforming each value into a new value using the <code>transform</code> closure
  and adding it to the supplied <code>collector</code>.
  <pre class="groovyTestCase">assert [1,2,3] as HashSet == [2,4,5,6].collect(new HashSet()) { (int)(it / 2) }</pre>
  
  @param self      an Iterable
  @param collector the Collection to which the transformed values are added
  @param transform the closure used to transform each item
  @return the collector with all transformed values added to it
  @since 2.5.0