How to insert double quotes into String with interpolation in scala

后端 未结 11 1588
北荒
北荒 2020-12-05 12:53

Having trouble escaping all the quotes in my function

(basic usage of it -> if i find a string do nothing, if its not a string add \" in the begin and end)

11条回答
  •  盖世英雄少女心
    2020-12-05 13:25

    It's heavily used in my case, therefore I created this version:

    object StringUtil{
        implicit class StringImprovements(s: String) {
            def quoted = "\""+s+"\""
        }
    }
    
    val myStatement = s"INSERT INTO ${tableName.quoted} ..."
    

提交回复
热议问题