例如:
code = <<-EOH
bundle install
bundle exec unicorn -c /etc/unicorn.cfg -D
EOH
Run Code Online (Sandbox Code Playgroud)
这段代码有什么作用?什么<<-
叫?
Ruby 还有一个更新的 HEREDOC 语法<<~END
,它更类似于您在大多数 shell 和其他语言中通常看到的语法,而不是~
告诉-
Ruby 去除前导空格以匹配块中缩进最少的行。
https://infinum.co/the-capsized-eight/multiline-strings-ruby-2-3-0-the-squiggly-heredoc