mirror of https://github.com/tinygo-org/tinygo.git
wasmstm32webassemblymicrocontrollerarmavrspiwasiadafruitarduinocircuitplayground-expressgpioi2cllvmmicrobitnrf51nrf52nrf52840samd21tinygo
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
205 B
14 lines
205 B
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
|
|
}
|
|
|