1 Feb 2005 16:37
Re: [groovy-dev] Re: thoughts on the closure/return/break/continue issue
On 1 Feb 2005, at 15:32, Martin C. Martin wrote:
> Guillaume Laforge wrote:
>>>
>>> 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?
>> Well, it depends if you think it's a bug or a feature
>> I think it's a bug.
>
> I think so too, and it should be pretty easy to fix. Basically, when
> adding the return, if the last statement is an "if," propagate the
> return to the if/else blocks. I'll start an issue.
>
> We can only do it for new groovy, if James thinks that's best.
Lets mull over the proposed change a few days first before coding it;
I've had another thought that could simplify the rules for
closures/methods with return/continue I'd like to express & get
feedback on.
By all means create a JIRA issue if you like - but lets delay a few
days implementing it, just to check we're happy with the semantics
we've come up with
James
-------
http://radio.weblogs.com/0112098/
RSS Feed