Skip to content

Instantly share code, notes, and snippets.

@fo2rist
Last active July 6, 2019 00:05
Show Gist options
  • Save fo2rist/d46bb95dbe4fc52474fad4a66affb739 to your computer and use it in GitHub Desktop.
Save fo2rist/d46bb95dbe4fc52474fad4a66affb739 to your computer and use it in GitHub Desktop.
// try-ignore approach
try {
doAction()
} catch (exc: SomePreconditionViolated) {
//ignore
} finally {
finalize()
}
/* ^ COMPARE v */
// check-and-execute approach
if (canDoTheAction()) {
doAction()
finalize()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment