Android ● ○ ○ Kotlin 2.0

Kodebits Day 30: Extension Function

May 27 2026
Practice extensions with a short kotlin challenge.

What is the output?

fun String.twice(): String {
  return this + this
}
fun main() {
  val s = "Ko"
  println(s.twice())
}


Try it in the online Kotlin Playground →

[spoiler title="Solution"]

Answer:

KoKo

Explanation:

Extension functions add new methods to existing types.

[/spoiler]


Further Reading