groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Wagenleitner (JIRA)" <>
Subject [jira] [Commented] (GROOVY-7935) Right side of assignment - remove parens or not?
Date Mon, 26 Sep 2016 05:00:27 GMT


John Wagenleitner commented on GROOVY-7935:

The following from the change throws a {{groovy.lang.MissingPropertyException: No such property:
bar for class: Test}} on 2.4.7 which is the same sort of error the single param foo method
gives when in a nested call.

def bar() { 1 }
def m = bar

It sounds like you might be referring to the [Method Pointer Operator (.&)|]
and that does work:

def bar() { 1 }
def m = this.&bar
assert m() == 1

But that is not what the example shows.  Would be happy to expand the wording of that section
if you have suggested wording or a PR would be welcomed as well.

> Right side of assignment - remove parens or not?
> ------------------------------------------------
>                 Key: GROOVY-7935
>                 URL:
>             Project: Groovy
>          Issue Type: Bug
>          Components: Documentation
>         Environment:, release 2.4.7
>            Reporter: tinne
>            Assignee: John Wagenleitner
>            Priority: Minor
>             Fix For: 2.4.8
> The Groovy [style guide|] says, "...  Groovy doesn’t
allow you to remove parentheses. [...] for nested method calls or on the right-hand side of
an assignment, you can’t omit them there."
> Then, a code fragment is given, where just this works.
> {noformat}
> def foo(n) { n }
> println foo 1 // won't work, as documented
> def m = foo 1 // this works indeed!
> {noformat}
> Further more, I could not find any examples, where this would not work, neither with
comma separated parameter lists nor with infix computations nor closures.
> So I guess it is just a documentation bug and right-hand side parens removal support
has been added.

This message was sent by Atlassian JIRA

View raw message