|
|
|
|
|
by gw
1946 days ago
|
|
Not the commenter but which one of these is the defer generating? // option 1
try {
fp = os.open(x)
fp.read()
}
finally {
fp.close()
}
// option 2
fp = os.open(x)
try {
fp.read()
}
finally {
fp.close()
}
Should we close if open fails? Maybe, maybe not, but with try/finally it is obvious which one it is doing. |
|