idioms - TonyGuyot/kotlin-notes GitHub Wiki

Kotlin idioms

String interpolation

    val name = "Tony"
    println("Name $name has ${name.length} characters")
  • $name will be replaced by its actual value
  • ${name.length} will be executed and replaced but the result of the execution (note the brackets)
  • the string displayed will be Name Tony has 4 characters