Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable string interpolation in Kotlin?

I have a text like "$ $abc $$abc ${a} ${}". I would like to completely disable string interpolation for the string and not to escape each and individual $ from the string. What should I do? In Scala you declare a string where interpolation is enabled with s"$ $abc $$abc ${a} ${}" while the normal string is not interpolated.

like image 390
raisercostin Avatar asked Mar 07 '23 02:03

raisercostin


1 Answers

String interpolation is available for both regular and raw strings ("""). So you need to escape them, which is easier in a regular String obviously (see here).

"$ \$abc \$\$abc \${a} \${}"

I'm sorry but there's no other way I'm afraid.

like image 99
s1m0nw1 Avatar answered Apr 03 '23 02:04

s1m0nw1