Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumKotlintailrec functionsSingle-choice MCQ

A function is marked `tailrec` and the recursive call is genuinely the last operation, but it is wrapped in a `try { ... }` block. What happens?

tailrec fun f(n: Int): Int { if (n <= 0) return 0 try { return f(n - 1) } finally { // cleanup } }