APPENDIX G MORE ON METHODS
A method that can make a call on itself is known as a recursive method. When the method makes a direct call on itself from within its own method body, we refer to this as direct recursion. When one method calls another that, in turn, calls the first again, we refer to this as indirect recursion. Recursion is an extremely powerful approach for expressing many elegant programming solutions.
In this appendix, we demonstrate recursive methods as well as other aspects of methods such as statically typed parameters and return values.
G.1 RECURSIVE METHODS
A method may invoke any other method. Programmers exploit this facility to build programs hierarchically, in which one method invokes submethods to perform subsidiary ...
Get Groovy Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.