Is there any difference between Groovy's non-argument grep() and findAll() methods?
groovy
Solution
Short answer: the result will be the same.
Long answer: `grep` normally uses a filter object, on which `isCase` is then called. As such the argument to grep normally is no Groovy Closure. For `findAll` you use a Closure as argument, and if the result of the Closure is evaluated to true, it is taken into the resulting collection.
Now it is important to know that a Closure has an isCase method as well. `Closure#isCase(Object)` will execute the Closure using the argument as argument for the Closure and the result of it is then evaluated using Groovy Truth. For an identity Closure, ie. `{it}`, this means the closure will return what is given to it, thus Groovy will apply Groovy Truth to the argument of the grep call. The result is then the same as with findAll.
Problem
From the Groovy JDK: public Collection grep() Iterates over the collection of items which this Object represents and returns each item that matches using the IDENTITY Closure as a filter - effectively returning all elements which satisfy Groovy truth. public Collection findAll() Finds all items matching the IDENTITY Closure (i.e. matching Groovy truth).