5 ms·
If you find the official release notes a bit dry (they really are), I've prepared an interactive version with lots of examples: - Iterators (range / types / pu
by nalgeon 2y ago
If you find the official release notes a bit dry (they really are), I've prepared an interactive version with lots of examples:
- Iterators (range / types / pull / slices / maps).
- Timer changes (garbage collection and reset/stop behavior).
- Canonical values with the `unique` package.
- HTTP cookie handling.
- Copying directories.
- Slices and atomics changes.
https://antonz.org/go-1-23 https://antonz.org/go-1-23
- danielvaughn 2y agoThank you for your service, this is awesome! I'd love to see language maintainers post interactive release notes like this.
- felixge 2y agoThis is great, thank you.
- metadat 2y agoI want to understand the purpose of maps.All(). In the example: m := map[string]int{"a": 1, "b": 2, "c": 3} for k, v := range maps.All(m) { fmt.Printf("%v:%v ", k, v) } fmt.Println("") for k, v := range m { fmt.Printf("%v:%v ", k, v) } These both output the same thing. What's the point of the addition? Slices.All() seems similarly redundant and pointless. Surely I must be misunderstanding something, I hope.
- sakjur 2y agoThey’re useful because they let you pass a slice or map to something built to handle the new func(func (…) bool) style iterators. If I create a IterateOver(fn func(func (K, V any) bool)) function, you cannot pass a slice since that doesn’t match fn’s type, but if you wrap it with slices.All it’ll work.
- deleted 2y ago[deleted]
- ianlancetaylor 2y agoYou can use it with other functions that use iterators. For example, here is code that makes a copy of a map keeping only the even keys. maps.Collect(xiter.Filter2(func(k, v int) bool { return k%2 == 0 }, maps.All(m)))
- monkfromearth 2y ago[dead]