3 ms·
what happens if x.dispose() throws an exception? if (x != null) try { x.dipose(); } catch (Exception){} } it's why the using keyword is so nice. Still, this i
by latch 16y ago
what happens if x.dispose() throws an exception?
if (x != null) try { x.dipose(); } catch (Exception){} }
it's why the using keyword is so nice. Still, this is all hoops languages force us to deal with when they shouldn't (which is the OPs point)
- JulianMorrison 16y agoYou're lucky Java is checked at compile time. Ruby would eat that "no such method dipose" and silently leak x.
- CodeMage 16y agoYou're lucky Java is checked at compile time. Not lucky enough, because x.dispose() could throw an unchecked exception.