123456789101112131415161718192021222324252627282930 |
-
- // MAP OMIT
- func Map[F, T any](s []F, f func(F) T) []T { ... }
- // MAP OMIT
-
-
- // MAP CALL OMIT
- var s []int
- f := func(i int) int64 { return int64(i) }
- var r []int64
- // Specify both type arguments explicitly.
- r = Map[int, int64](s, f)
- // Specify just the first type argument, for F,
- // and let T be inferred.
- r = Map[int](s, f)
- // Don't specify any type arguments, and let both be inferred.
- r = Map(s, f)
-
- // MAP CALL OMIT
-
-
- // ERR OMIT
-
- func Double[T interface{ ~int }](v T) T {
- return v * 2
- }
-
- Double(1) //
-
- // ERR OMIT
|