Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6121

Object[].groupBy is not defined

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.3
    • 2.2.0-beta-1
    • groovy-jdk
    • None
    • Mac OS X, JDK8 ("1.8.0-ea-b83")

    Description

      groupBy(Closure) GDK method is defined only on java.util.Collection, but array(Object[]) lacks it.
      For example,

      groovy -e 'println((["ab","ba","ac"] as String[]).groupBy{ it[0] })'
      Caught: groovy.lang.MissingMethodException: No signature of method: [Ljava.lang.String;.groupBy() is applicable for argument types: (script_from_command_line$_run_closure1) values: [script_from_command_line$_run_closure1@4f209819]
      Possible solutions: grep(), grep(), grep(java.lang.Object), drop(int), countBy(groovy.lang.Closure), grep(java.lang.Object)

      On the other hand, countBy{} is defined on Object[].
      Is there any reason with this asymmetry?

      Attachments

        Activity

          People

            paulk Paul King
            uehaj UEHARA Junji
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: