Apols for hijacking this a little, but it's related! (honest) I've been thinking recently about the setup of Groovy and particularly the extension methods. For questions like this, it would seem sensible to build an extension method to do it, but currently the expected place is to put it into Groovy itself. Therefore needing a release of Groovy to incorporate it.
Now that the extension method API is well understood and seemingly stable, would it be feasible to separate the lifecycle of the extension methods/ GDK out from the Groovy runtime itself? That way Peters proposed extension could be implemented there without needing an upgrade of Groovy itself, and could then be usable on older versions of the language. Sound sane at all? On 22 May 2015 at 15:13, Peter Ledbrook <[email protected]> wrote: > Hi, > > One of the things I really like about Groovy is how strings can be treated > as sequences of characters. Unfortunately this seems to break down in some > cases. For example, there is no `count()` method that takes a closure. In > my case I'm trying to count vowels, but you might want to count upper case > letters or anything else like that. > > Does it make sense to extend all the Iterable methods and properties to > CharSequence as well? Or should developers turn a string into a list, > perform the processing and then convert it back? Either way, the current > setup seems a bit inconsistent. > > Peter > > -- David Dawson CEO Simplicity Itself Limited Tel +44 7866 011 256 Skype: davidadawson [email protected] http://www.simplicityitself.com
