package main

import (
	"fmt"
	"slices"
)

func main() {
	// section: example
	items := []string{"first", "second", "third", "fourth"}

	// slices.Backward returns an iterator that yields
	// index-value pairs in reverse order
	fmt.Println("Using slices.Backward:")
	for i, v := range slices.Backward(items) {
		fmt.Printf("  index %d: %s\n", i, v)
	}

	// Unlike slices.Reverse, this doesn't modify the original slice
	fmt.Println("Original slice unchanged:", items)
	// section: example
}
