Last active
February 21, 2022 05:24
-
-
Save tlehman/2d68a61d3945949485668b711251ad70 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 main | |
| import ( | |
| "fmt" | |
| ) | |
| func double[T int | float64](x T) T { | |
| return T(2) * x | |
| } | |
| func main() { | |
| var a int = 5 | |
| var adbl = double(a) | |
| var b float64 = 5.5 | |
| var bdbl = double(b) | |
| fmt.Printf("adbl = %d, bdbl = %f\n", adbl, bdbl) | |
| } |
tlehman
commented
Feb 21, 2022
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment