4 ms·
Just to play devil's advocate, here's what that example would look like with exceptions and something like `using()` in C# (here, any curly block can implicitly
by munificent 15y ago
Just to play devil's advocate, here's what that example would look like with exceptions and something like `using()` in C# (here, any curly block can implicitly be treated like a try block, like in Ruby):
package main
import (
"io"
"log"
"os"
)
func cat(name string) {
using (f := os.Open(name)) {
io.Copy(os.Stdout, f)
}
}
func main() {
for _, arg := range os.Args[1:] {
cat(arg);
} catch (err os.Error) {
log.Print(err)
}
}