Standard library / slices
slices.All()
Yields index and element pairs in ascending index order. Stops when the consumer ends iteration. Expected stdout: '0 a\n1 b\n'.
Formal Syntax & Structure
go syntaxgo
func All[Slice ~[]E, E any](s Slice) iter.Seq2[int, E]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | Slice | Input slice; may share its backing array. |
Return Value
iter.Seq2[int, E]
Yields index and element pairs in ascending index order. Stops when the consumer ends iteration.
Working Example
Example Snippetgo
package main
import ( "fmt" "slices")
func main() { for i, v := range slices.All([]string{"a", "b"}) { fmt.Println(i, v) }}