jastrachan | 1 Feb 15:39 2005
Picon

Re: [groovy-dev] Re: thoughts on the closure/return/break/continue issue


On 1 Feb 2005, at 14:34, Martin C. Martin wrote:

>
>
> Guillaume Laforge wrote:
>>>>>  list.inject(0) { sum, i | if (i % 2 == 1) sum else sum+i*i }
>>>
>>> FWIW, the first one doesn't parse:
>> But this parses and runs:
>> println( (1..10).inject(0) { sum, i | if (i % 2 == 1) return sum; else
>> return sum+i*i } )
>
> Doh!  Thanks Guillaume.  Glad I emailed here before starting an issue.
>
> However,
>
> print ( [-2, -6, 5].collect { if (it < 0) -it; else it } )
>
> results in "[null, null, null]."  If I put a "return" in front of -it 
> and/or it, I get the proper values for <0 / >=0 respectively.  Is that 
> a bug or a feature?  Will it be changed in new groovy?  Should I start 
> an issue?

This thread was started on the JSR email list to discuss the New Groovy 
syntax. We might as well leave Classic Groovy as it is for now

James
-------
http://radio.weblogs.com/0112098/


Gmane