I've been trying to learn how to create an `All() iter.Seq[T]` method for a simple set type (a map wrapper):
playground <https://go.dev/play/p/wtWvvTf33AF?v=gotip> It won't work in the playground of course, but when I do: `GOEXPERIMENT=rangefunc go run .` using Go 1.22 I get this error: ``` cannot use func(yield func(int, T) bool) {…} (value of type func(yield func(int, T) bool)) as iter.Seq[T] value in return statement ``` Can someone help me get this right please? ``` package main import ( "cmp" "fmt" "iter" ) func main() { s := New(5, 10, 15, 20, 35) for v := range s.All() { fmt.Println(v) } } type Set[T cmp.Ordered] map[T]struct{} func New[T cmp.Ordered](elements ...T) Set[T] { set := make(Set[T], len(elements)) for _, element := range elements { set[element] = struct{}{} } return set } func (me Set[T]) All() iter.Seq[T] { return func(yield func(int, T) bool) { // ERROR n := 0 for key := range me { if !yield(n, key) { return } n++ } } } ``` -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/73161d74-12eb-4be0-9ea4-a35a25758e8en%40googlegroups.com.