concept return in category groovy
appears as: return, returns

This is an excerpt from Manning's book Groovy in Action, Second Edition.
In chapter 7, we’ll talk about optional return statements.
Listing 7.6. Declaring parameter lists
class ClassWithTypedAndUntypedMethodParams { static void main(args) { assert 'untyped' == method(1) assert 'typed' == method('whatever') assert 'two args' == method(1, 2) } static method(arg) { return 'untyped' } static method(String arg) { return 'typed' } static method(arg1, Number arg2) { return 'two args' } }
Internally, the least upper bound is also used to compute the inferred return type of a method or a closure. For that, the type checker collects all return expressions (both explicit, using the return keyword, and implicit, without return) and compares their inferred type to the declared method return type. If any of the return statement isn’t compatible with the return type, an error is thrown. If, as expected, all returns are compatible, the inferred return type of the method is computed as the least upper bound of all returns.