Generics
- Allows a function to receive type parameters
func sumSlice[T int | float32 | float64](slice []T) {
var sum T
for _, v := range slice {
sum += v
}
return sum
}- We can also use the any type to allow a function to take in any type
func bar[T any] {...}
- Can also be used with structs
type car [T gasEngine | electricEngine] struct {...}