不含插值的 Heredoc
October 14, 2020
有时你想用 Ruby 的 Heredoc,但不希望它做插值('#{....}')。只要给你的标识符加上一对单引号就能做到:
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
有时你想用 Ruby 的 Heredoc,但不希望它做插值('#{....}')。只要给你的标识符加上一对单引号就能做到:
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