3 ms·
The one mentioned in the article. It's not a hack: it's a runtime equivalent that requires that your type implements some interface.
by haolez 7y ago
The one mentioned in the article.
It's not a hack: it's a runtime equivalent that requires that your type implements some interface.
- btilly 7y agoIt is a hack. The article lists a whole series of things that are standard in other languages that you can't do in go. Here are some examples: Find smallest/largest element in slice Find average/standard deviation of slice Compute union/intersection of maps Find shortest path in node/edge graph Apply transformation function to slice/map, returning new slice/map And here are data structures that other languages have but go does not: Sets Self-balancing trees, with efficient insertion and traversal in sorted order Multimaps, with multiple instances of a key Concurrent hash maps, supporting parallel insertions and lookups with no single lock If it were not a hack, then go would not have these limitations.
- majewsky 7y ago> Multimaps, with multiple instances of a key Isn't this just map[Key][]Value? The standard library uses these in several places, e.g. url.Values and http.Header, with assorted utility functions.
- btilly 7y agoYou should send that feedback to the author of the article. I literally just cut and pasted those lists.