On 22 December 2011 11:52, Wujek Srujek <
wujek....@googlemail.com> wrote:
> Hi. I am having some trouble finding any relevant difference between grep
> and findAll - it looks like grep is a more specific case, where the argument
> has its isCase method called for each instance in a collection, which can
> always be done with findAll as well. I can imagine that for example this:
> list.grep(~/blah/)
> is faster than
> list.findAll { it ==~ /blah/ }
> as it compiles the pattern only once (I suppose?), but otherwise I see no
> real difference.
Looking at the source, I'm not convinced `grep` is faster than
`findAll`. It has to go through MetaClass to invoke `isCase` on a
filter. There is no such step in `findAll`.
> Are there any conventions as to when you one and when the other? Or is any
> of these deprecated?
Personally, I use `findAll`, but, honestly, never gave it much thought.
Cheers,
Dinko
>
> wujek
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email