RubyMine
 
Get RubyMine

Extract/Introduce variable

Last modified: 23 October 2024

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/2024.3/rm_refactoring_extract_variable.png
Gif

To extract a variable: