Extract parameter
Last modified: 27 December 2022Refactor | Extract/Introduce | Parameter
Ctrl+Alt+F
The Extract Parameter refactoring is used to add a new parameter to a method declaration and to update the method calls accordingly.
The animation below demonstrates how to add a method parameter by extracting a value from a string:

To extract a parameter:
Select a value to refactor or place a caret at a string containing the required value.
From the main menu, select Refactor | Extract/Introduce | Parameter Ctrl+Alt+P.
(Optional) If you place a caret at a place containing several expressions available for extracting, select the required expression and press Enter:
In the invoked dialog, specify the parameter name and type:
You can use various parameter types such as positional, array, keyword and so on.
Click Refactor.
Example
Before | After |
---|---|
|
|
Thanks for your feedback!