mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 10:37:46 +00:00
bb65c5ce2b
...that was surprisingly easy.
15 lines
205 B
Go
15 lines
205 B
Go
package main
|
|
|
|
func main() {
|
|
println("add:", Add(3, 5))
|
|
println("add:", Add(int8(3), 5))
|
|
}
|
|
|
|
type Integer interface {
|
|
int | int8 | int16 | int32 | int64
|
|
}
|
|
|
|
func Add[T Integer](a, b T) T {
|
|
return a + b
|
|
}
|