The compiler accepts (playground)
package main
import "fmt"
func main() {
for a := range f {
fmt.Println(a)
}
}
func f(yield func(...int) bool) {
yield(1)
yield(1, 2)
yield(1, 2, 3)
}
yet the spec does not explicitly allow this.
It is also confusing because the type of the yield function argument (...int in this case) does not match the type of the iterator variable ([]int in this case).
The compiler accepts (playground)
yet the spec does not explicitly allow this.
It is also confusing because the type of the yield function argument (
...intin this case) does not match the type of the iterator variable ([]intin this case).