---
title: "不含插值的 Heredoc"
description: "有时你想用 Ruby 的 Heredoc，但不希望它做插值（'#{....}'）。只要给你的标识符加上一对单引号就能做到："
canonical: https://oozou.com/til/heredoc-without-interpolation-74
locale: zh-Hans
date: 2020-10-14
topic: ruby
---

# 不含插值的 Heredoc

> 有时你想用 Ruby 的 Heredoc，但不希望它做插值（'#{....}'）。只要给你的标识符加上一对单引号就能做到：

Published: 2020-10-14 · Topic: [ruby](https://oozou.com/zh-Hans/til-topics/ruby) ([markdown](https://oozou.com/zh-Hans/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-Hans/contact

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