Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文档 [Go 泛型的 3 个核心设计,你学会了吗? ]中的Code是不是有误 #161

Open
huiyangz opened this issue Mar 21, 2022 · 0 comments

Comments

@huiyangz
Copy link

文档 Go 泛型的 3 个核心设计,你学会了吗? 中的Code是不是有误。

type SC[E any] interface {
	[]E   //  ~[]E  ???
}

func DoubleDefined[S SC[E], E constraints.Number](s S) S {
	r := make(S, len(s))
	for i, v := range s {
		r[i] = v + v
	}
	return r
}
var V2 = DoubleDefined[MySlice, int](MySlice{1})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant