Extract method
Extract a function or a method
The Extract Method refactoring lets you take a code fragment that can be grouped together, move it into a separated method and replace the old code with call to the method. If the code always exits in return statements (all execution paths lead to possibly implicit return statements), it is extracted as is. However, if it contains execution paths without returns, the extracted method will have an additional bool
flag as a return
value. The flag is used to perform an early return on the call side.
In the editor, select an expression or its part that you want to extract. You can also position the caret within the expression, in this case GoLand offers you a list of potential code selections.
Press Ctrl+Alt+M or from the main menu, select
.Type a method name and press Enter.