Created
April 22, 2015 06:17
-
-
Save aspyker/a03d263491cc80a4a5bb to your computer and use it in GitHub Desktop.
question on exception handling and scala val/var
This file contains 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
// trying to use a val (what I'd like to do somehow) | |
try { | |
val someThing = getSomeThingThatCouldThrowException() | |
} | |
finally { | |
if (someThing != null) someThing.close() | |
} | |
// foreced to use a var (what works) | |
var something = null | |
try { | |
someThing = getSomeThingThatCouldThrowException() | |
} | |
finally { | |
if (someThing != null) someThing.close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment