Björn Kautler created GROOVY-11802:
--------------------------------------
Summary: Method return type documentation is wrong
Key: GROOVY-11802
URL: https://issues.apache.org/jira/browse/GROOVY-11802
Project: Groovy
Issue Type: Documentation
Reporter: Björn Kautler
The documentation about method return types is quite wrong.
It for example says "Methods in Groovy always return some value" which is not
true if it is declared as {{{}void{}}}.
It also says "return type or with the {{def}} keyword" which is not correct as
you can also have both and also can have neither.
And it says "{{{}def{}}} keyword, to make the return type untyped" which is
also not correct if you specify {{def}} and a return type.
The truth as far as I know and tried is, if you do not specify a return type
explicitly (like {{void}} or an actual type), you have a dynamic return type /
untyped return type / flexible return type / however you want to name it,
`MethodNode` names it
{{{}org.codehaus.groovy.ast.MethodNode#isDynamicReturnType{}}}.
And {{def}} is just there to disambiguate some cases that would otherwise be
unclear to the parser probably, and can even be combined with {{{}void{}}}.
You need it e. g. if you have {{foo() \{ }}} or {{{}<T> T foo() \{ null }{}}},
but not if you e. g. have {{static foo() \{ }}} or {{{}private foo() \{ }{}}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)