code: public static <K,E> Map<K, Integer> countBy(E[] self, @ClosureParams(FirstParam.Component.class) Closure<K> closure) {
          return countBy((Iterable)Arrays.asList(self), closure);
      }
docs: Sorts all array members into groups determined by the supplied mapping
  closure and counts the group size.  The closure should return the key that each
  item should be grouped by.  The returned Map will have an entry for each
  distinct key returned from the closure, with each value being the frequency of
  items occurring for that group.
  <p>
  Example usage:
  <pre class="groovyTestCase">assert ([1,2,2,2,3] as Object[]).countBy{ it % 2 } == [1:2, 0:3]</pre>
  
  @param self    an array to group and count
  @param closure a closure mapping items to the frequency keys
  @return a new Map grouped by keys with frequency counts
  @see #countBy(Collection, Closure)
  @since 1.8.0