groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alessio Stalla <alessiosta...@gmail.com>
Subject Re: Aw: Do closures always return a value?
Date Fri, 04 Dec 2015 11:23:02 GMT
In that case, I would either define different methods or use a different
sentinel value to indicate pruning, like a public static Object PRUNE = new
Object(); somewhere. Then, the each method does not do if(closure())
it.prune() but if(PRUNE == closure()) it.prune().

On Fri, Dec 4, 2015 at 12:14 PM, Felix Dorner <felix.dorner@gmail.com>
wrote:

>
>
> while (iterator.hasNext()){
>>      Object next = it.next()
>>      doSomethingWith(next)
>>      if (!childrenAreInteresting(next)){
>>      it.prune() // this skips the subtree of the current element
>>      }
>> }
>>
> This should be iterator.prune()
>

Mime
View raw message