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

Provide a collectAll() method for lists (WAS: Provide a 'SpreadAllDot' operator)

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.5, 1.5.1
    • 1.5.2
    • None
    • None

    Description

      Currently we have list*.method() that invokes the method on all items in the list.
      It would be useful to also support list**.method() that invokes the method on all items in the list and recursively for any lists within the list.

      def animalLists= [["ant", "mouse", "elephant"], ["deer", "monkey"]]
      assert animalLists.size() == 2
      assert animalLists*.size() == [3, 2]
      assert animalLists**.size() == [[3, 5, 8], [4, 6]]
      

      Attachments

        Activity

          People

            paulk Paul King
            paulk Paul King
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: