Android ● ● ● Kotlin 2.0

Kodebits Day 60: Inline Function

Jul 18 2026
Practice inline with a short kotlin challenge.

What does this print?

inline fun run(f: () -> Unit) {
  f()
}
fun check(n: Int): Int {
  run {
    if (n < 5) return 0
  }
  return n
}
fun main() {
  println(check(3))
}


Try it in the online Kotlin Playground →

[spoiler title="Solution"]

Answer:

0

Explanation:

Inline functions enable non-local returns. The return inside the lambda returns from check(), not the lambda. Without inline, this code wouldn't compile.

[/spoiler]


Further Reading