3 ms·
Right it mentions it when casting to Duck. The post makes it read like casting to `interface { Quack() }` was a problem, when really it was the ignoring of the
by karmakaze 2y ago
Right it mentions it when casting to Duck. The post makes it read like casting to `interface { Quack() }` was a problem, when really it was the ignoring of the error return value from that cast.
- vips7L 2y agoThe language shouldn’t let you silently ignore errors.
- akira2501 2y agoIt's not silent. It will panic.
- candleknight 2y agobut that'll be at runtime
- mplewis 2y agoIn Go, a runtime panic indicates a programmer error. This means you should not have written that line of code. The solution is to fix the line of code.
- Thaxll 2y agoEvery languages let you ignore errors, Rust included.
- nhumrich 2y agoThe fact that the error happens _at run time_ is exactly the point. Whether the error is handled or not has nothing to do with the point of the post.
- karmakaze 2y agoI didn't think anyone was under the impression that Go (or Java, or many other statically-typed languages) have sound type systems. For better/worse there are often intentional and unintentional escape hatches. Go also has an 'unsafe' package that can mess things up at runtime--don't do that and don't ignore errors.