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

range generics list type error #70842

Closed
epowsal opened this issue Dec 14, 2024 · 1 comment
Closed

range generics list type error #70842

epowsal opened this issue Dec 14, 2024 · 1 comment

Comments

@epowsal
Copy link

epowsal commented Dec 14, 2024

Go version

go 1.23.1 windows amd64

Output of go env in your module/workspace:

not need

What did you do?

define type:
type QuickSets[T any] []*QuickSet[T]

add func:
func (qs *QuickSets[T]) Clac(cmpf func(a, b T) int) (c []T) {
as1 := [][]T{}
for qi, a := range qs {
as1 = append(as1, qs[qi])
}
return c
}

What did you see happen?

cannot range over qs (variable of type *QuickSets[T])

What did you expect to see?

make it can range

@Jorropo
Copy link
Member

Jorropo commented Dec 14, 2024

Try *qs, you can't range nor index pointer to slices to begin with:

a := []int{42}
b := &a
for range b // does not work
b[0] = 1337 // does not work

@Jorropo Jorropo closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2024
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

2 participants