groovy

eachLine should support a 2 arg closure with index being second arg

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.5.4
  • Fix Version/s: 1.5.5, 1.6-beta-1
  • Component/s: groovy-jdk
  • Labels:
    None
  • Number of attachments :
    0

Description

It would be good to be able to support an index on eachLine as follows:

file.eachLine { line, count -> println "$count > $line" }

Activity

Hide
Alexander Veit added a comment -

The reported line numbers should start with 0. See http://jira.codehaus.org/browse/GROOVY-2905.

Show
Alexander Veit added a comment - The reported line numbers should start with 0. See http://jira.codehaus.org/browse/GROOVY-2905.
Hide
Paul King added a comment -

Re: 'The reported line numbers should start with 0'

Depends on if we decide to go that way in the referenced issue.

Show
Paul King added a comment - Re: 'The reported line numbers should start with 0' Depends on if we decide to go that way in the referenced issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: