4 ms·
And here's what it might have looked like if they had taken notes from a language with a good exception handling style: using(File f = os.Open(filename)) {
by WorldWideWayne 12y ago
And here's what it might have looked like if they had taken notes from a language with a good exception handling style:
using(File f = os.Open(filename)) {
callFunctionThatMightErrorOut()
}
Thanks to exceptions, `using` doesn't have to access the return value from `os.Open`, it just has to handle the exception that it (or any code inside the `using` block) might raise. Also thanks to exceptions, using can automatically cleanup `File`. Without exceptions, this simple pattern would not work very well at all.