Android ● ● ○ Kotlin 2.0

Kodebits Day 38: Infix Function

Jun 10 2026
Practice infix functions with a short kotlin challenge.

What does this print?

infix fun Int.times2(n: Int): Int {
  return this * n * 2
}
fun main() {
  val r = 3 times2 4
  println(r)
}


Try it in the online Kotlin Playground →

[spoiler title="Solution"]

Answer:

24

Explanation:

Infix functions allow calling with natural syntax between operands.

[/spoiler]


Further Reading