Re:Avoiding Reflection (And Such) in Go
by infogulch on Saturday December 05, 2015 @03:14PM
(#10683115)
Here's one way you could do the clipping generically in Go[1]. This has a Clip function that uses a type assertion. Another (perhaps better) implementation would add Clip methods to both Rect and Poly.
Either way, I don't think this example proves the necessity of generics. Some algorithms are certainly more difficult to express in Go (graph data structures/algorithms in particular in my personal experience).
Either way, I don't think this example proves the necessity of generics. Some algorithms are certainly more difficult to express in Go (graph data structures/algorithms in particular in my personal experience).
[1]: https://play.golang.org/p/xYQWDS41A0