fun doSomething() {} fun test(n: Int) { var res: String? = null var foo: String? = null res = try { "success" } catch (e: Exception) { throw e } finally { if (n == 1) doSomething() else foo = "finally" } }