Example
| Before | After |
|---|---|
function multiplication(a,b) { c = a + b; d = c * c; return d; } |
function sum(a,b); return a + b; function multiplication(a,b) { c = sum(a,b); d = c * c; return d; } |
- In the editor, select a block of code to be transformed into a function.
Tip
The selected code fragment does not necessarily have to be a set of statements. It may also be an expression used somewhere in the code.
- On the main menu or on the context menu of the selection, choose or press Ctrl+Alt+MCtrl+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.

