String literals

Kotlin has string literal support in the following code:

var message = "Hello, World
"; 
print(message);

Also, unlike Java, Kotlin has multiline string support, as seen in the following code:

var csv = """
Name,Telephone,Email
Shazin,07743299201,[email protected]
""".trimIndent();
println(csv);

A multiline string literal begins and ends with three double quotes ("""). Inside this, special double quotes can be used without escaping, which is very handy. The trimIndent() method trims the indentations inside the string in the preceding code. Without it the string literal will contain tabs and spacing exactly as shown in the previous code; this is shown in the following code:

    Name,Telephone,Email
Shazin,07743299201,[email protected]
..................Content has been hidden....................

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