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

A `tailrec` function whose recursive call is wrapped in a `try { ... }` block produces a compiler warning and is NOT optimized. Why?

tailrec fun loop(n: Int): Int { return try { if (n <= 0) 0 else loop(n - 1) } catch (e: Exception) { -1 } }