Search⌘ K

Quiz: Deduce the Outputs

Explore key aspects of Go structs and methods by deducing outputs in this quiz. Learn to understand how data structures and methods interact in Go, preparing you for advanced topics like interfaces.

We'll cover the following...

Choose one correct answer

1.

What’s wrong with the following code?

package main
import "container/list"

func (p *list.List) Iter() {
	// ...
}
func main() {
  lst := new(list.List)
  for _ = range lst.Iter() {
  }
}
A.

lst is not a pointer type object

B.

Cannot define new methods on non-local type list.List

C.

lst.Iter undefined (type *list.List has no field or method Iter)

D.

Both B and C

E.

All of the above


1 / 6

We hope that you ...