Generics
Key Concepts
Type Parameters
func PrintSlice[T any](slice []T) {
for _, v := range slice {
fmt.Println(v)
}
}Constraints
func Add[T int | float64](a, b T) T {
return a + b
}any Constraint
any ConstraintBenefits
Examples
Generic Functions
Generic Types
Multiple Type Parameters
New Constraints
Last updated