In Java, Following code is one way to achieve.
StringBuilder result = new StringBuilder();
result.append(someChar);
result.append("\n");
Idiomatic way of doing it in kotlin?
In Java, Following code is one way to achieve.
StringBuilder result = new StringBuilder();
result.append(someChar);
result.append("\n");
Idiomatic way of doing it in kotlin?
Kotlin 1.3 provides Extension Function to ease the task.
Usage:
val strBuilder = StringBuilder()
strBuilder.appendln("some text")
In Kotlin 1.4 appendln()
is deprecated and appendLine() is introduced.
Usage:
val strBuilder = StringBuilder()
strBuilder.appendLine("some text")
© 2022 - 2024 — McMap. All rights reserved.