paul paul - 3 months ago 10
Scala Question

delete this please

This question is not longer valid and because seems people getting annoying, it would be good if can be deleted

Answer

Can val jsonAlbum= new JSONObject(json.asInstanceOf[Map[String, Any]]) throw NoSuchElementException? If not, just declare jsonAlbum before that try/catch block. If yes, you wouldn't see correct value of jsonAlbum in catch block anyway, because it's creation failed.

Note that you can use something like

val a = try { ... } catch { ... }

if you want to keep visibility without code garbage.