GROOVY-7935: fix style guide example for required parentheses
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/37161f95 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/37161f95 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/37161f95 Branch: refs/heads/master Commit: 37161f95e50abb018bb0c3523aecd948f88555d7 Parents: f42c34b Author: John Wagenleitner <jwagenleit...@apache.org> Authored: Wed Sep 21 22:20:50 2016 -0700 Committer: John Wagenleitner <jwagenleit...@apache.org> Committed: Wed Sep 21 22:20:50 2016 -0700 ---------------------------------------------------------------------- src/spec/doc/style-guide.adoc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/37161f95/src/spec/doc/style-guide.adoc ---------------------------------------------------------------------- diff --git a/src/spec/doc/style-guide.adoc b/src/spec/doc/style-guide.adoc index 240e047..5458d0d 100644 --- a/src/spec/doc/style-guide.adoc +++ b/src/spec/doc/style-guide.adoc @@ -209,16 +209,15 @@ list.each { println it } Always prefer the third form, which is more natural, as an empty pair of parentheses is just useless syntactical noise! -There are some cases where Groovy doesn't allow you to remove parentheses. -As I said, top-level expressions can omit them, but for nested method calls or on the right-hand side of an assignment, -you can't omit them there. +In some cases parentheses are required, such as when making nested method calls or when calling a method without parameters. [source,groovy] ---- def foo(n) { n } +def bar() { 1 } println foo 1 // won't work -def m = foo 1 +def m = bar // won't work ---- == Classes as first-class citizens