String templates are used to insert a variable’s value into a string. String literals may contain template expressions, i.e. pieces of code that are evaluated and whose results are concatenated into the string.
A template expression starts with a dollar sign ($) and consists of either a simple name.
Value is 5
Anything in the curly brackets starting with a $ sign will be evaluated and the result will be put in the string.
Sum is 11
Kotlin String template with raw string
We have already seen how to use string template with escaped string. Now, we will see how to use string templates with raw string.
Like escaped string, string template in raw string starts with $ sign.
I hope the description was understandable and clear. But if you have still questions, then leave me comments below! 😉
Have a nice a day! 🙂