code: public static <T, A, R extends Collection<A>> R collect(
              Iterable<T> iterable,
              Function<? super T, ? extends A> function,
              R targetCollection)
      {
          if (iterable instanceof RichIterable)
          {
              return ((RichIterable<T>) iterable).collect(function, targetCollection);
          }
          if (iterable instanceof ArrayList)
          {
              return ArrayListIterate.collect((ArrayList<T>) iterable, function, targetCollection);
          }
          if (iterable instanceof RandomAccess)
          {
              return RandomAccessListIterate.collect((List<T>) iterable, function, targetCollection);
          }
          if (iterable != null)
          {
              return IterableIterate.collect(iterable, function, targetCollection);
          }
          throw new IllegalArgumentException("Cannot perform a collect on null");
      }
docs: Same as the {@link #collect(Iterable, Function)} method with two parameters, except that the results are gathered into the specified
  targetCollection
  <p>
  Example using a Java 8 lambda expression:
  <pre>
  MutableList&lt;String&gt; names =
  Iterate.<b>collect</b>(people, person -> person.getFirstName() + " " + person.getLastName(), FastList.newList());
  </pre>
  <p>
  Example using an anonymous inner class:
  <pre>
  MutableList&lt;String&gt; names =
  Iterate.<b>collect</b>(people,
  new Function&lt;Person, String&gt;()
  {
  public String value(Person person)
  {
  return person.getFirstName() + " " + person.getLastName();
  }
  }, FastList.newList());
  </pre>