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

Wrong example in the api of class Map(dropWhile)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.1.8, 2.2.0-rc-1
    • None
    • None

    Description

      In the api of class map, is the example in the description for the method dropWhile(Closure closure) incorrect.
      http://groovy.codehaus.org/groovy-jdk/java/util/Map.html#dropWhile(groovy.lang.Closure)

      def shopping = [milk:1, bread:2, chocolate:3]
      assert shopping.takeWhile{ it.key.size() < 6 } == [milk:1, bread:2]
      assert shopping.takeWhile{ it.value % 2 } == [milk:1]
      assert shopping.takeWhile{ k, v -> k.size() + v <= 7 } == [milk:1, bread:2]
      

      It must be

      def shopping = [milk:1, bread:2, chocolate:3]
      assert shopping.dropWhile{ it.key.size() < 6 } == [milk:1, bread:2]
      assert shopping.dropWhile{ it.value % 2 } == [milk:1]
      assert shopping.dropWhile{ k, v -> k.size() + v <= 7 } == [milk:1, bread:2]
      

      Attachments

        Activity

          People

            paulk Paul King
            janschumacher Jan Schumacher
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 10m
                10m
                Remaining:
                Remaining Estimate - 10m
                10m
                Logged:
                Time Spent - Not Specified
                Not Specified