Last active
June 17, 2020 13:43
-
-
Save goldeneggg/119310436c7f873e8506705b6ba417cf to your computer and use it in GitHub Desktop.
Go2 (with Generics) experimental. See: https://blog.golang.org/generics-next-step and https://go.googlesource.com/go/+/refs/heads/dev.go2go/README.go2go.md
This file contains 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 Print(type T)(s []T) { | |
for _, v := range s { | |
fmt.Println(v) | |
} | |
} | |
func main() { | |
a := []int{1, 2, 3, 4, 5} | |
b := []float64{1.1, 2.2, 3.3, 4.4, 5.5} | |
Print(a) | |
Print(int)(a) | |
Print(b) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ go tool go2go run hoge.go2 warning: GOPATH set to GOROOT (/Users/fskmt/goroot) has no effect 1 2 3 4 5 1 2 3 4 5 1.1 2.2 3.3 4.4 5.5