https://kotlinlang.org logo
d

diesieben07

06/11/2018, 2:17 PM
Would it be desirable to allow usage of the string-interpolation syntax in a user-defined way? I am imagining something like this (hand-wavy syntax ahead):
Copy code
fun sql(template: StringTemplate): String = template.process { name, value ->
    escapeSql(value)
}
val name = "Bob"
val query = sql("SELECT * FROM users where name = $name") // will correctly escape the injected string
1