The `finally` Block in `try-catch-finally` Executes Always

15 · Vishnu Haridas · Sept. 22, 2020, 5:04 p.m.
Summary
Today I was exploring a Jetpack Compose sample project source code, and at one point I found a code that implements a Mutex. Here’s what it looks like (from kotlinx-couroutines-core, ) lock(owner) try { return action() } finally { unlock(owner) } I was wondering how they are going to release the mutex lock within the finally block once the return action() inside the try block is executed. I never wrote a finally block before, so this got me a little confused. A...