---
title: "式展開なしの Heredoc"
description: "Ruby の Heredoc を式展開（'#{....}'）なしで使いたいことがあります。キーワードの前後にシングルダッシュを追加することで実現できます："
canonical: https://oozou.com/til/heredoc-without-interpolation-74
locale: ja
date: 2020-10-14
topic: ruby
---

# 式展開なしの Heredoc

> Ruby の Heredoc を式展開（'#{....}'）なしで使いたいことがあります。キーワードの前後にシングルダッシュを追加することで実現できます：

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

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