Created
March 4, 2014 22:11
-
-
Save hiroshiro/5c217fe548b3508e600d to your computer and use it in GitHub Desktop.
複数行の文字列を格納する。Rubyのコード"def test\n some_method\n other_method\nend\n"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
code = <<-END.gsub(/^\s+\|/, '') | |
|def test | |
| some_method | |
| other_method | |
|end | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
複数行のヒアドキュメントを用いるときは、 先頭のスペースも保持してしまうということを頭に入れておかなければなりません。 過剰なスペースを取り除くためのマージンを採用するのを実用的です。