---
title: "不含插值的 Heredoc"
description: "有時你會想使用 Ruby 的 Heredoc 但不進行插值（'#{....}'）。只要在你的關鍵字前後加上單引號就可以做到："
canonical: https://oozou.com/til/heredoc-without-interpolation-74
locale: zh-Hant
date: 2020-10-14
topic: ruby
---

# 不含插值的 Heredoc

> 有時你會想使用 Ruby 的 Heredoc 但不進行插值（'#{....}'）。只要在你的關鍵字前後加上單引號就可以做到：

Published: 2020-10-14 · Topic: [ruby](https://oozou.com/zh-Hant/til-topics/ruby) ([markdown](https://oozou.com/zh-Hant/til-topics/ruby.md))

有時你會想使用 Ruby 的 Heredoc 但不進行插值（'#\{....}'）。只要在你的關鍵字前後加上單引號就可以做到：

```ruby
doc = <<-'SONG'
Business men, they drink my wine
#{person} dig my earth
None will level on the line
Nobody offered his word
Hey, hey
SONG
```

---

Contact OOZOU: hello@oozou.com · +66 2544 0000 · https://oozou.com/zh-Hant/contact

More for AI agents: https://oozou.com/llms.txt · every page has a markdown twin at its URL plus ".md"
