What does it mean by "receiver appears in its own argument list"?

I’m learning Go. In the Go tour in Methods topic, I see the following sentences,

A method is a function with a special receiver argument.
The receiver appears in its own argument list between the func keyword and the method name.

What is the meaning of the part “the receiver appears in its own argument list”. Which argument list is this? Why is it calling it a list? Can one method be applied to multiple types?

This is really confusing me. Looking for an explanation from experience members here.

Reference:
Methods Tour of Go

That’s probably not the best wording. There’s a detailed description here The Go Programming Language Specification - The Go Programming Language. Note the sentence near the end, this is probably the source of “argument list” description in the tour: "The type of a method is the type of a function with the receiver as first argument. "

2 Likes

Thanks for the link to the specification section for Methods. It cleared my doubt. About the last sentence that you are referring to in the specification section is followed by “However, a function declared this way is not a method.” So the wording “argument list” makes no sense either way.
I come from Java background and I am finding, the syntax in Go particularly when it comes to creation and use of user defined types and interfaces is not really explicit.
Let me see if my view changes after gaining more familiarity with this language. :slight_smile:

Basically, it means that a method can be passed or assigned wherever the function type is needed. For example:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.