RubyMine
 
Get RubyMine
You are viewing the documentation for an earlier version of RubyMine.

Extract/Introduce variable

Last modified: 09 August 2022

Refactor | Extract/Introduce | Variable

Ctrl+Alt+V

The Extract Variable refactoring lets you extract a specified value to a corresponding variable. You can use this refactoring for basic Ruby data types (for example, strings, arrays, hashes) and class instances.

The animation below demonstrates how to extract a specific word from a string to a variable:

https://resources.jetbrains.com/help/img/idea/2022.2/rm_refactoring_extract_variable.png
Gif

To extract a variable: