26 Jan 2005 15:39
Re: [groovy-dev] Diff of Java and Groovy grammars
On 26 Jan 2005, at 14:31, Guillaume Laforge wrote:
>> But if you really didn't wanna return the value of the last
>> expression,
>> use an explicit return
>>
>> String foo() {
>> toString()
>> return null
>> }
>
> Hmmm, it's not very bueatiful
> It's a "hack" !
>
> Let's consider this:
>
> def foo() {
> someStatement()
> }
>
> If someStatement() returns a value, the value would automatically be
> returned?
> What if I *don't* want to return anything, not even null? How would I
> do that?
>
> For closures, I'm okay if we don't require the return keyword for a
> single-statement/expression closure, but for methods or functions,
> that looks ugly or hackish
Agreed, it does smell a bit! :)
I think we have to treat closures differently anyway (return & break
have different meanings) so we can solve both use cases neatly (see
previous mail)
James
-------
http://radio.weblogs.com/0112098/
RSS Feed