The tutorial could begin with something simple and general, such as:
func PrintAll[T any](s []T) {
for x := range s {
fmt.Println(x)
}
}
or a function motivated by
https://go.dev/doc/faq#convert_slice_of_interface such as:
func Convert[T any](s []T) []any {
r := make([]any, len(s))
for i, v := range s {
r[i] = v
}
return r
}
and then progressively introduce examples with more restrictive constraints as specific methods or operators become necessary.
Instead, it adopts a bottom-up approach, beginning with extremely specific constraints and then broadening the type sets, without culminating in examples that utilize the most general constraint, 'any'.
This situation often leads to many developers beginning their journey with generics using [T A|B], mistakenly treating it as sum types. Consequently, they resort to type switches, resulting in dissatisfaction and a call for the resolution of
https://github.com/golang/go/issues/45380.