Created
October 13, 2017 03:04
-
-
Save michaelbartnett/ebde61e77ecf358402905a7cac8c00e2 to your computer and use it in GitHub Desktop.
Looking for tricky interactions between closures and exceptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let print = console.log | |
| let closure = null | |
| try { | |
| let x = 42 | |
| let y = null | |
| closure = (msg) => { | |
| x = x + 1 | |
| print(msg, x, y) | |
| } | |
| throw "no good" | |
| y = 99 | |
| } catch (error) { | |
| try { | |
| print('caught error: ', error) | |
| closure('in nested try: ') | |
| print(y + 1) | |
| } finally { | |
| closure('in finally: ') | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment