[ https://issues.apache.org/jira/browse/GROOVY-7432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14560699#comment-14560699 ]
Paul King commented on GROOVY-7432: ----------------------------------- We probably need something like: {code} private static final class StringIterable implements Iterable<String> { private final CharSequence delegate; public StringIterable(CharSequence delegate) { this.delegate = delegate; } @Override public Iterator<String> iterator() { return new StringIterator(delegate); } } {code} And ditto for CharacterIterable: {code} private static final class CharacterIterable implements Iterable<Character> { private final CharSequence delegate; public CharacterIterable(CharSequence delegate) { this.delegate = delegate; } @Override public Iterator<Character> iterator() { return new CharacterIterator(delegate); } } {code} Let me know if you want me to add them separate to your PR. > Enhance CharSequence with appropriate Iterable extension methods > ---------------------------------------------------------------- > > Key: GROOVY-7432 > URL: https://issues.apache.org/jira/browse/GROOVY-7432 > Project: Groovy > Issue Type: Improvement > Components: groovy-jdk > Reporter: Peter Ledbrook > Assignee: Guillaume Laforge > > Groovy enables developers to treat {{CharSequence}}s as if they were true > sequences. For example, you can use a for loop and the array index operator. > Some extension methods are missing though. One I was hoping to find was the > {{count(Closure)}} method. I think it makes sense to incorporate any > {{Iterable}} extension methods into {{CharSequence}} as well. -- This message was sent by Atlassian JIRA (v6.3.4#6332)