The detected output variable is used as a return value for the extracted function.
To extract a function
- In the editor, select a block of code to be transformed into a function.
- On the main menu or on the context menu of the selection, choose Refactor | Extract Method or press Ctrl+Alt+M.
- In the Extract Function dialog box that opens, specify the name of the new function.
- To have the new function defined through a function expression, select the Declare functional expression check box.
In the Parameters area, configure the set of variables to be passed to the new function as parameters.
By default, all the variables from the specified scope are listed.
- To have a variable included in the parameter set, select the check box next to it.
- To change the order of parameters, use the Move Up and Move Down buttons.
- View and check the declaration of the function to be generated in the Signature preview read-only area.