Last active
August 8, 2018 03:47
-
-
Save guiprav/80cd2ece770366c99efc2c832026cb92 to your computer and use it in GitHub Desktop.
Use finally sim
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
function transfereDollares(de, para, quantos) { | |
let pegouError = false; | |
try { | |
// [...] (codigos com retorne) | |
} catch (err) { | |
pegouError = true; | |
throw err; | |
} finally { | |
if (pegouError) { | |
return; | |
} | |
// [...] (coisas rodadas depois de qualquer retorne) | |
// (Otima solusao para o problema de reúso de codigo \o/) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment