如果我创建一个 Here 文档:
myheredoc = <<HTMLOUTPUT
<div>This is the div</div>
HTMLOUTPUT
我可以使用“myheredoc”来像处理常规字符串一样操作此 Here 文档吗?
最佳答案
当然可以。语法是为了让它更容易阅读,你仍然只是在创建一个字符串。
>> myheredoc = <<HTMLOUTPUT
<div>This is the div</div>
HTMLOUTPUT
=> "<div>This is the div</div>\n"
>> myheredoc << "<p>some paragraph</p>"
=> "<div>This is the div</div>\n<p>some paragraph</p>"
关于ruby - 是否可以在创建 Here 文档后对其进行编辑?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1433906/