Groovy
  1. Groovy
  2. GROOVY-4932

groovy should provide a shorthand for: collect{}.flatten()

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8.1
    • Component/s: None
    • Labels:
      None

      Description

      This functionality is already available via Collection#sum(Closure) as shown here:

      def nums = 1..10
      def squaresAndCubesOfEvens = nums.sum{ it % 2 ? [] : [it**2, it**3] }
      assert squaresAndCubesOfEvens == [4, 8, 16, 64, 36, 216, 64, 512, 100, 1000]
      

      however the name sum is not intuitive in all scenarios and sum is not always the most efficient was to concatenate such lists as it directs through the Groovy 'plus' operator to allow custom overriding of 'plus'.

      The intention is to provide a collectMany "alias" for sum which is more efficient and has naming similar to C#'s Enumerable.SelectMany operator.

        Issue Links

          Activity

          paulk@asert.com.au created issue -
          Paul King made changes -
          Field Original Value New Value
          Resolution Fixed [ 1 ]
          Fix Version/s 1.8.1 [ 17223 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Paul King made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Pascal Schumacher made changes -
          Link This issue is duplicated by GROOVY-6443 [ GROOVY-6443 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
          Mark Thomas made changes -
          Workflow jira [ 12733858 ] Default workflow, editable Closed status [ 12745419 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
          Mark Thomas made changes -
          Workflow jira [ 12971658 ] Default workflow, editable Closed status [ 12979477 ]
          Mark Thomas made changes -
          Reporter Paul King [ paulk@asert.com.au ] Paul King [ paulk ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          42m 14s 1 Paul King 19/Jul/11 10:27
          Resolved Resolved Closed Closed
          2d 9h 39m 1 Paul King 21/Jul/11 20:06

            People

            • Assignee:
              Paul King
              Reporter:
              Paul King
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development