尝试在 Ruby 中格式化多行字符串
heredoc并且%q{ }存在它们包含用于格式化代码的空格的问题。
s = %q{Foo
Bar
Baz}
puts s
错误地输出以下内容:
Foo
Bar
Baz
以下作品,但对人物来说有点难看\。
s = "Foo\n" \
" Bar\n" \
" Baz"
puts s
以下适用于python:
s = ("Foo\n"
" Bar\n"
" Baz")
print s
Ruby中是否有等价物?