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

DGM#collectEntries has a Collection variant but no Object[] variant

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.8-beta-2
    • 1.8-beta-3
    • None
    • None

    Description

      def letters = "abc"
      def nums = [0, 1, 2] as Integer[]
      // collect letters with index using list style
      assert nums.collectEntries { index -> [index, letters[index]] } == [0:'a', 1:'b', 2:'c']
      // collect letters with index using map style
      assert nums.collectEntries { index -> [(index): letters[index]] } == [0:'a', 1:'b', 2:'c']
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: