Ruby: Can I write multi-line string with no concatenation?

后端 未结 16 861
礼貌的吻别
礼貌的吻别 2020-12-04 04:42

Is there a way to make this look a little better?

conn.exec \'select attr1, attr2, attr3, attr4, attr5, attr6, attr7 \' +
          \'from table1, table2, ta         


        
16条回答
  •  囚心锁ツ
    2020-12-04 05:33

    You can also use double quotes

    x = """
    this is 
    a multiline
    string
    """
    
    2.3.3 :012 > x
     => "\nthis is\na multiline\nstring\n"
    

    If needed to remove line breaks "\n" use backslash "\" at the end of each line

提交回复
热议问题