I don’t understand the following code snippet in the container/heap package.
type Interface interface {
sort.Interface //Is this line a method?
Push(x interface{})
Pop() interface{}
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is a type declaration.
The
heap.Interfaceinterface embeds thesort.Interfaceinterface.You can see it as a kind of inheritance/specialization : it means that the structs implementing the
heap.Interfaceinterface are defined as the ones that implement thesort.Interfacemethods and thePushandPopmethods.Interface embeding is described in Effective Go : http://golang.org/doc/effective_go.html#embedding