Created
April 14, 2022 07:30
-
-
Save damithadayananda/9b40bd4de496ce93f9b5e474390ee52a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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