[ 
https://issues.apache.org/jira/browse/GROOVY-7432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14559021#comment-14559021
 ] 

Paul King edited comment on GROOVY-7432 at 5/26/15 12:02 PM:
-------------------------------------------------------------

General comment: you might want to take a look at the latest {{dropWhile}} and 
{{takeWhile}} implementations on master - the previously mentioned anomaly has 
been fixed. Plus they support explicit char/Character arg variants as well as a 
default/explicit String arg.

{{collate}} does make sense - but probably with return type {{List<String>}} 
rather than nested lists:
{code}
assert "abcdefg".collate(3) == ["abc", "def", "g"]
{code}

I would regard {{collectReplacements}} as a suitable alternative to 
{{collectMany}}.

Closure versions of min/max would indeed map via SAM coercion if only a 
Comparator version existed but a dedicated Closure version would handle the one 
and two-arg variants, e.g. "aBc".min{ a, b -> b.toUpperCase() <=> 
a.toUpperCase() }



was (Author: paulk):
General comment: you might want to take a look at the latest {{dropWhile}} and 
{{takeWhile}} implementations on master - the previously mentioned anomaly has 
been fixed.

{{collate}} does make sense - but probably with return type {{List<String>}} 
rather than nested lists:
{code}
assert "abcdefg".collate(3) == ["abc", "def", "g"]
{code}

I would regard {{collectReplacements}} as a suitable alternative to 
{{collectMany}}.

Closure versions of min/max would indeed map via SAM coercion if only a 
Comparator version existed but a dedicated Closure version would handle the one 
and two-arg variants, e.g. "aBc".min{ a, b -> b.toUpperCase() <=> 
a.toUpperCase() }


> 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)

Reply via email to