I'm using string with triple quote inside of string with triple quote:
fun main(args: Array<String>) {
val firstStr = """
OLOLO
""".trimIndent()
val secondStr = """
$firstStr
new added text
""".trimIndent()
println("The firstStr is $firstStr")
println("The secondStr is $secondStr")
}
and I've got the following output:
The firstStr is
OLOLO
The secondStr is
OLOLO
new added text
And I'm confused why the indent remains on the last line (" new added text")... Because I expected that trimIndent() method had to trim all indent (as documentation comment says this method
Detects a common minimal indent of all the input lines, removes it from every line and also removes the first and the last lines if they are blank (notice difference blank vs empty).
And at the same time I can cut this indent with trimMargin() with default parameter ("|"):
fun main(args: Array<String>) {
val firstStr = """
OLOLO
""".trimIndent()
val secondStr = """
$firstStr
|new added text
""".trimMargin()
println("The firstStr is $firstStr")
println("The secondStr is $secondStr")
}
In this case I've got the following output:
The firstStr is
OLOLO
The secondStr is
OLOLO
new added text
But I can't understand why trimIndent() doesn't trim that indent...