# 内联

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

> **TL;DR**
> `重构 | 内联`
>
>
>
> `Ctrl+Alt+N` (Windows), `⌘ ⌥ N` (macOS), `⌘ ⌥ N` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ N` (macOS System Shortcuts), `Ctrl+Alt+N` (XWin), `Ctrl+Alt+N` (GNOME), `Ctrl+Alt+N` (KDE), `Ctrl+Alt+N` (Emacs), `Ctrl+Alt+N` (Sublime Text), `⌘ ⌥ N` (Sublime Text (macOS)), `Ctrl+R, I` (Visual Studio), `⌘ R, I` (Visual Studio (macOS)), `Meta+Alt+N` (TextMate), `Ctrl+Alt+N` (NetBeans), `Alt+Shift+I` (Eclipse), `⌘ ⌥ I` (Eclipse (macOS))

目前，RubyMine 提供  内联函数  重构，它与 [提取方法](extract-method.html) 重构相反。

通过  内联 重构，您可以撤销针对变量和方法的提取重构。

下面的动画演示了如何将变量内联为字符串：

![内联变量](https://resources.jetbrains.com/help/img/idea/2026.3/rm_refactoring_inline_variable.animated.gif)

要内联变量/方法：

Procedure:

1. 将插入符号放置在变量/方法名称处。

2. 按 `Ctrl+Alt+N` (Windows), `⌘ ⌥ N` (macOS), `⌘ ⌥ N` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ N` (macOS System Shortcuts), `Ctrl+Alt+N` (XWin), `Ctrl+Alt+N` (GNOME), `Ctrl+Alt+N` (KDE), `Ctrl+Alt+N` (Emacs), `Ctrl+Alt+N` (Sublime Text), `⌘ ⌥ N` (Sublime Text (macOS)), `Ctrl+R, I` (Visual Studio), `⌘ R, I` (Visual Studio (macOS)), `Meta+Alt+N` (TextMate), `Ctrl+Alt+N` (NetBeans), `Alt+Shift+I` (Eclipse), `⌘ ⌥ I` (Eclipse (macOS)) 或进入主菜单中的  `重构 | 内联` 。

3. 在与所选变量或方法对应的   内联  对话框中，指定内联选项。 预览并应用更改。

## 内联变量

内联变量 重构将冗余的变量使用替换为其初始化器。 此重构与 [提取变量](extract-variable.html)相反。

|  之前  |  之后  |
| --- | --- |
|     ```RUBY name = "JetBrains" puts "Hello from #{name}"  ```    |     ```RUBY puts "Hello from JetBrains"  ```    |

## 内联方法

内联方法  会将方法的主体置于它的调用者的主体中。

|  之前  |  之后  |
| --- | --- |
|     ```RUBY def test   c=add(a,b)   d=add(a,c) end  def add(a, b)   a+b end  ```    |     ```RUBY def test   c = a + b   d = a + c end  ```    |

## See also

### 操作步骤

[重构代码](refactoring-source-code.html)

### 操作步骤

[提取/引入变量](extract-variable.html) [Extracting variables in Style Sheets](null)

### 外部链接

[Inline method](http://blog.jetbrains.com/ruby/2012/01/whats-mining-inline-method-refactoring/)

