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

后端 未结 16 820
礼貌的吻别
礼貌的吻别 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:24

    Elegant Answer Today:

    <<~TEXT
    Hi #{user.name}, 
    
    Thanks for raising the flag, we're always happy to help you.
    Your issue will be resolved within 2 hours.
    Please be patient!
    
    Thanks again,
    Team #{user.organization.name}
    TEXT
    

    Theres a difference in <<-TEXT and <<~TEXT, former retains the spacing inside block and latter doesn't.

    There are other options as well. Like concatenation etc. but this one makes more sense in general.

    If I am wrong here, let me know how...

提交回复
热议问题