mactsouk/mastering-Go-3rd

type constrait syntax error

carlosandrefernandes opened this issue · 1 comments

//fixing syntax error on numeric.go (ch13) line 8:
package main

import (
"fmt"
)

type Numeric interface {
int | int8 | int16 | int32 | int64 | float64
}

func Add[T Numeric](a, b T) T {
return a + b
}

func main() {
fmt.Println("4 + 3 =", Add(4,3))
fmt.Println("4.1 + 3.2 =", Add(4.1,3.2))
}

@carlosandrefernandes Please open a pull request with the changes so I can test them. Thanks!