Skip to content

Instantly share code, notes, and snippets.

@aspyker
Created April 22, 2015 06:17
Show Gist options
  • Save aspyker/a03d263491cc80a4a5bb to your computer and use it in GitHub Desktop.
Save aspyker/a03d263491cc80a4a5bb to your computer and use it in GitHub Desktop.
question on exception handling and scala val/var
// 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