commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Noah Levitt (JIRA)" <j...@apache.org>
Subject [jira] Commented: (IO-181) LineIterator should implement Iterable
Date Tue, 17 Nov 2009 06:01:43 GMT

    [ https://issues.apache.org/jira/browse/IO-181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12778738#action_12778738
] 

Noah Levitt commented on IO-181:
--------------------------------

I strongly agree with the bug reporter, LineIterator should implement Iterable. Then you can
write nice code like this:

for (String line: new LineIterator(reader)) {
    // ...
}

Maybe I'm missing something, but if this is the implementation of iterator(), how can it be
abused?

    public Iterator<String> iterator() {
        return this;
    }


> LineIterator should implement Iterable 
> ---------------------------------------
>
>                 Key: IO-181
>                 URL: https://issues.apache.org/jira/browse/IO-181
>             Project: Commons IO
>          Issue Type: Improvement
>    Affects Versions: 1.4
>            Reporter: Michael Ernst
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> org.apache.commons.io.LineIterator does not implement Iterable.  This makes
> it impossible to use in certain stylized ways, such as in a new-style for
> statement.  Such use is not always desirable (it might temporarily leak a
> file descriptor, until the finalizer is called), but should be possible in
> situations where it is known to be acceptable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message