Skip to content

Instantly share code, notes, and snippets.

@damithadayananda
Created April 14, 2022 07:30
Show Gist options
  • Save damithadayananda/9b40bd4de496ce93f9b5e474390ee52a to your computer and use it in GitHub Desktop.
Save damithadayananda/9b40bd4de496ce93f9b5e474390ee52a to your computer and use it in GitHub Desktop.
package typeInference
import (
"fmt"
"golang.org/x/exp/constraints"
)
func TypeInferenceDemo(){
fmt.Println(GenericAdd(2,4))
}
func GenericAdd[T constraints.Integer](x,y T)T{
return x + y
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment