Groovy
  1. Groovy
  2. GROOVY-4865

Add a take method to Collections, Iterators, Arrays

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8.1, 1.9-beta-1
    • Component/s: groovy-jdk
    • Labels:
      None

      Description

      With regards to a thread in the groovy user list here:

      http://groovy.329449.n5.nabble.com/How-to-access-first-10-characters-even-if-string-only-have-5-td4456146.html

      A take( n ) method would be a really useful addition to the Groovy codebase

      It is assumed it will work similar to other languages, in that:

      def a = [ 1, 2, 3 ]
      
      assert a.take( 0 ) == []
      assert a.take( 1 ) == [ 1 ]
      assert a.take( 4 ) == [ 1, 2, 3 ]
      

      The method should work for Collection, String, Map and lazily for Iterator, Reader and InputStream

        Issue Links

          Activity

          Tim Yates created issue -
          Tim Yates made changes -
          Field Original Value New Value
          Attachment initial_take_for_List_Array_and_Iterator.diff [ 55435 ]
          Dinko Srkoc made changes -
          Attachment second_take_with_drop_for_List_Array_and_Iterator.diff [ 55439 ]
          Tim Yates made changes -
          Attachment initial_take_for_List_Array_and_Iterator.diff [ 55435 ]
          Tim Yates made changes -
          Attachment third_cumulative_pass_take_for_CharSequence_Reader_InputStream.diff [ 55445 ]
          Tim Yates made changes -
          Attachment fourth_pass_drop_for_CharSequence.diff [ 55453 ]
          Tim Yates made changes -
          Attachment third_cumulative_pass_take_for_CharSequence_Reader_InputStream.diff [ 55445 ]
          Dinko Srkoc made changes -
          Attachment second_take_with_drop_for_List_Array_and_Iterator.diff [ 55439 ]
          Tim Yates made changes -
          Attachment fifth_iteration.diff [ 55465 ]
          Tim Yates made changes -
          Attachment fourth_pass_drop_for_CharSequence.diff [ 55453 ]
          Dinko Srkoc made changes -
          Attachment sixth_iteration.diff [ 55469 ]
          Tim Yates made changes -
          Attachment fifth_iteration.diff [ 55465 ]
          Tim Yates made changes -
          Attachment sixth_iteration_returning_iterators.diff [ 55472 ]
          Tim Yates made changes -
          Attachment seventh_iteration.diff [ 55473 ]
          Tim Yates made changes -
          Attachment sixth_iteration_returning_iterators.diff [ 55472 ]
          Dinko Srkoc made changes -
          Attachment sixth_iteration.diff [ 55469 ]
          Tim Yates made changes -
          Attachment eighth_iteration.diff [ 55488 ]
          Tim Yates made changes -
          Attachment seventh_iteration.diff [ 55473 ]
          Tim Yates made changes -
          Attachment eighth_iteration.diff [ 55488 ]
          Tim Yates made changes -
          Attachment eighth_iteration.diff [ 55489 ]
          Guillaume Delcroix made changes -
          Assignee Guillaume Laforge [ guillaume ]
          Guillaume Delcroix made changes -
          Summary Add a take method to Collections, Iterators, Readers and InputStreams Add a take method to Collections, Iterators, Arrays
          Guillaume Delcroix made changes -
          Resolution Fixed [ 1 ]
          Fix Version/s 1.9-beta-1 [ 17153 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 1.8.1 [ 17223 ]
          Paul King made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Paul King made changes -
          Link This issue relates to GROOVY-5414 [ GROOVY-5414 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
          Mark Thomas made changes -
          Workflow jira [ 12733792 ] Default workflow, editable Closed status [ 12745602 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
          Mark Thomas made changes -
          Workflow jira [ 12971331 ] Default workflow, editable Closed status [ 12979122 ]

            People

            • Assignee:
              Guillaume Delcroix
              Reporter:
              Tim Yates
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development