Skip to content

Instantly share code, notes, and snippets.

@mbn18
Created September 15, 2017 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbn18/b9052187984cba8e8f12bda17a8474bd to your computer and use it in GitHub Desktop.
Save mbn18/b9052187984cba8e8f12bda17a8474bd to your computer and use it in GitHub Desktop.
Why the second range fail?
type list []*item
// Work
for g := range *list {
z := *list
println(z[g].Name)
}
// Fail
for g := range *list {
println(*list[g].Name)
}
@mbn18
Copy link
Author

mbn18 commented Sep 15, 2017

Error is

./garden.go:26:16: invalid operation: list[g] (type *Garden.Gardens does not support indexing)
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment