# Extract parameter

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/ruby/2026.3/llms.txt).

> **TL;DR**
> `Refactor | Extract/Introduce | Parameter`
>
>
>
> `Ctrl+Alt+P` (Windows), `⌘ ⌥ P` (macOS), `⌘ ⌥ P` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ P` (macOS System Shortcuts), `Ctrl+Alt+P` (XWin), `Ctrl+Alt+P` (GNOME), `Ctrl+Alt+P` (KDE), `Ctrl+Alt+P` (Emacs), `Ctrl+Alt+P` (Sublime Text), `⌘ ⌥ P` (Sublime Text (macOS)), `Ctrl+R, P` (Visual Studio), `⌘ R, P` (Visual Studio (macOS)), `Meta+Alt+P` (TextMate), `Ctrl+Alt+P` (NetBeans), `Ctrl+Alt+P` (Eclipse), `⌘ ⌥ P` (Eclipse (macOS))

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:

![extract parameter](https://resources.jetbrains.com/help/img/idea/2026.3/rm_refactoring_extract_parameter.animated.gif)

To extract a parameter:

Procedure:

1. Select a value to refactor or place the caret at a string containing the required value.

2. In the main menu, go to `Refactor | Extract/Introduce | Parameter` `Ctrl+Alt+P` (Windows), `⌘ ⌥ P` (macOS), `⌘ ⌥ P` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ P` (macOS System Shortcuts), `Ctrl+Alt+P` (XWin), `Ctrl+Alt+P` (GNOME), `Ctrl+Alt+P` (KDE), `Ctrl+Alt+P` (Emacs), `Ctrl+Alt+P` (Sublime Text), `⌘ ⌥ P` (Sublime Text (macOS)), `Ctrl+R, P` (Visual Studio), `⌘ R, P` (Visual Studio (macOS)), `Meta+Alt+P` (TextMate), `Ctrl+Alt+P` (NetBeans), `Ctrl+Alt+P` (Eclipse), `⌘ ⌥ P` (Eclipse (macOS)).

3. (Optional) If you place the caret at a place containing several expressions available for extracting, select the required expression and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (TextMate), `Enter` (NetBeans), `Enter` (Eclipse), `⏎` (Eclipse (macOS)):

![expressions for extracting](https://resources.jetbrains.com/help/img/idea/2026.3/rm_refactoring_extract_parameter_expressions.png)

4. In the invoked dialog, specify the parameter name and type:

![Extract Parameter dialog](https://resources.jetbrains.com/help/img/idea/2026.3/rm_refactoring_extract_parameter_dialog.png)

You can use various parameter types such as positional, array, keyword and so on.

5. Click Refactor.

## Example

| Before | After |
| --- | --- |
|     ```RUBY def greet   puts "Hello from JetBrains" end  greet ```    |     ```RUBY def greet(name)   puts "Hello from #{name}" end  greet("JetBrains") ```    |

## See also

### Procedures

[Extracting parameters in JavaScript](specific-javascript-refactorings.html#javascript_extract_parameter)

### Reference

### External Links

