Standard library / reflect
reflect.Value.Seq2()
Returns a Go 1.23 two-value iterator with range-like semantics, such as index and element for slices. Expected stdout: '0:1 1:2 2:3 done\n'.
Formal Syntax & Structure
go syntaxgo
func (v Value) Seq2() iter.Seq2[Value, Value]Return Value
iter.Seq2[Value, Value]
Returns a Go 1.
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
func main() { s := reflect.ValueOf([]int{1, 2, 3}) for i, x := range s.Seq2() { fmt.Printf("%d:%d ", i.Int(), x.Int()) } fmt.Println("done")}