String concatenation and interpolation

String concatenation in Kotlin uses the plus (+) operator:

val temperature = 12

println("Current temperature: " + temperature + " Celsius degrees")

String interpolation is an easy way to do complex concatenations:

val temperature = 12

println("Current temperature: $temperature Celsius degrees")

Using the symbol dollar ($) lets you use simple values inside a string:

val temperature = 12

println("Temperature for tonight: ${temperature - 4} Celsius degrees")

For anything more complex than just using values, you can use a dollar symbol with braces (${... }):

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.71.21