Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas

PatilShreyas/StringTempl2.kt.diff Secret

Last active Dec 29, 2020
Embed
What would you like to do?
fun main() {
displayInfo("John Doe", 10)
}
fun displayInfo(name: String, age: Int) {
- val info = "Hi there!👋 My name is \"" + name + "\".\nI'm " + age + " years old."
+ val info = """
+ |Hi there!👋 My name is "$name".
+ |I'm $age years old.
+ """.trimMargin()
println(info)
// prints
// "Hi there!👋 My name is John Doe.
// I'm 10 years old."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment