Skip to content

Instantly share code, notes, and snippets.

@damithadayananda
Created April 14, 2022 07:11
Show Gist options
  • Save damithadayananda/740a7ee95c8dcde4c7dce5d6704a6396 to your computer and use it in GitHub Desktop.
Save damithadayananda/740a7ee95c8dcde4c7dce5d6704a6396 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"golang.org/x/exp/constraints"
)
func main() {
fmt.Println(GenericMul[float32](2.1,3.2))
}
func GenericMul[T constraints.Float](x, y T) T {
if x< y{
return x * y
}
return x/(y)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment