Commit be560e04 authored by Rob Pike's avatar Rob Pike

reflect: add a couple of sentences explaining how Methods operate.

R=rsc, gri, rsc1, bsiegert
CC=golang-dev
https://golang.org/cl/4183053
parent 65ece708
...@@ -235,10 +235,16 @@ type Type interface { ...@@ -235,10 +235,16 @@ type Type interface {
// Kind returns the specific kind of this type. // Kind returns the specific kind of this type.
Kind() Kind Kind() Kind
// For non-interface types, Method returns the i'th method with receiver T. // Method returns the i'th method in the type's method set.
// For interface types, Method returns the i'th method in the interface. //
// NumMethod returns the number of such methods. // For a non-interface type T or *T, the returned Method's Type and Func
// fields describe a function whose first argument is the receiver.
//
// For an interface type, the returned Method's Type field gives the
// method signature, without a receiver, and the Func field is nil.
Method(int) Method Method(int) Method
// NumMethods returns the number of methods in the type's method set.
NumMethod() int NumMethod() int
uncommon() *uncommonType uncommon() *uncommonType
} }
...@@ -444,7 +450,7 @@ func (t *FuncType) Out(i int) Type { ...@@ -444,7 +450,7 @@ func (t *FuncType) Out(i int) Type {
// NumOut returns the number of function output parameters. // NumOut returns the number of function output parameters.
func (t *FuncType) NumOut() int { return len(t.out) } func (t *FuncType) NumOut() int { return len(t.out) }
// Method returns the i'th interface method. // Method returns the i'th method in the type's method set.
func (t *InterfaceType) Method(i int) (m Method) { func (t *InterfaceType) Method(i int) (m Method) {
if i < 0 || i >= len(t.methods) { if i < 0 || i >= len(t.methods) {
return return
...@@ -458,7 +464,7 @@ func (t *InterfaceType) Method(i int) (m Method) { ...@@ -458,7 +464,7 @@ func (t *InterfaceType) Method(i int) (m Method) {
return return
} }
// NumMethod returns the number of interface methods. // NumMethod returns the number of interface methods in the type's method set.
func (t *InterfaceType) NumMethod() int { return len(t.methods) } func (t *InterfaceType) NumMethod() int { return len(t.methods) }
// Key returns the map key type. // Key returns the map key type.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment