[SOLVED] String interpolation - strange error


val str = s"abc = \"${quickSearchQuery.value}\""

I get the following error:

invalid escape at terminal index 6 in "abc = \". Use \\ for literal \. s"abc = \"${quickSearchQuery.value}\""

but this works fine:

val str = s"abc = " + "\"" + quickSearchQuery.value + "\""

Can anyone explain to me what is wrong with the first expression?

No idea where this is documented in detail - I don’t see it explicitly spelled out in the string interpolation doc and I also have a hard time interpreting the grammar. But I think double quotes cannot be contained (or escaped) in “single double quote” interpolated strings; you’ll have to use the “triple double quote” variant:

s"""abc = "${quickSearchQuery.value}""""

Thank you for your answer!