groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Ledbrook <pe...@cacoethes.co.uk>
Subject Re: CharSequence.count(Closure)
Date Sat, 23 May 2015 09:22:38 GMT
>
> Currently you'd need to do something like:
>
> "hello".iterator().count{ "aeiou".contains(it) }
>
> I think it makes sense to add a direct DGM method in this instance.
> And yes, I suspect that CharSequence versions of most of the Iterable
> DGM methods would be appropriate.
>

Should these go in DGM or StringGroovyMethods? I'm thinking the simplest
solution would be implementations of the form:

    static int count(CharSequence seq, Closure cl) {
        return count(seq.iterator(), cl);
    }

Does that make sense?

Peter

Mime
View raw message