Inline
Last modified: 16 October 2025
Currently, CLion provides the Inline Function refactoring, which is opposite to the Extract method refactoring.
The Inline refactoring lets you reverse the extract refactoring for variables and methods.
The animation below demonstrates how to inline a variable to a string:
To inline a variable/method:
- Place a caret at the variable/method name.
- Press
CtrlAlt0Nor go to Refactor \ Inline in the main menu. - In the Inline dialog that corresponds to the selected variable or method, specify the inlining options. Preview and apply changes.
Inline Variable
The Inline Variable refactoring replaces redundant variable usage with its initializer. This refactoring is opposite to Extract Variable.
| Before | After |
|---|---|
ruby<br>name = "JetBrains"<br>puts "Hello from #{name}"<br> |
ruby<br>puts "Hello from JetBrains"<br> |
Inline Method
Inline Method results in placing method's body into the body of its caller(s).
| Before | After |
|---|---|
ruby<br>def test<br> c=add(a,b)<br> d=add(a,c)<br>end<br>def add(a, b)<br> a+b<br>end<br> |
ruby<br>def test<br> c = a + b<br> d = a + c<br>end<br> |