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

The DGM removeAll variants which take a closure can be refactored to use removeIf for better efficiency

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.5
    • groovy-jdk
    • None

    Description

      We'd want all of the normal variations to work unchanged:

      def list = ['a', 'b']
      list.removeAll { it == 'b' }
      assert list == ['a']
      
      def m1 = [a:1, b:2]
      m1.removeAll { k,v -> k == 'b' }
      assert m1 == [a:1]
      def m2 = [a:1, b:2]
      m2.removeAll { k,v -> v == 1 }
      assert m2 == [b:2]
      def m3 = [a:1, b:2]
      m3.removeAll { e -> e.key == 'b' }
      assert m3 == [a:1]
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: