Breaking up long strings on multiple lines in Ruby without stripping newlines

后端 未结 5 1961
心在旅途
心在旅途 2020-12-12 09:37

We recently decided at my job to a ruby style guide. One of the edicts is that no line should be wider than 80 characters. Since this is a Rails project, we often have strin

5条回答
  •  有刺的猬
    2020-12-12 10:20

    Maybe this is what you're looking for?

    string = "line #1"\
             "line #2"\
             "line #3"
    
    p string # => "line #1line #2line #3"
    

提交回复
热议问题