]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: trivial addition: Value.NumMethod.
authorRob Pike <r@golang.org>
Thu, 14 Jul 2011 00:38:15 +0000 (10:38 +1000)
committerRob Pike <r@golang.org>
Thu, 14 Jul 2011 00:38:15 +0000 (10:38 +1000)
Just an oversight it was missing.

R=rsc, dsymonds, bradfitz, r
CC=golang-dev
https://golang.org/cl/4695059

src/pkg/reflect/value.go

index bfeb3267c7c3a746a075d11570a3453e3d6f6ecf..82985c5751a9e97a77728b1f42e684acf857bef4 100644 (file)
@@ -1025,6 +1025,15 @@ func (v Value) Method(i int) Value {
        return Value{v.Internal, i + 1}
 }
 
+// NumMethod returns the number of methods in the value's method set.
+func (v Value) NumMethod() int {
+       iv := v.internal()
+       if iv.kind == Invalid {
+               panic(&ValueError{"reflect.Value.NumMethod", Invalid})
+       }
+       return iv.typ.NumMethod()
+}
+
 // MethodByName returns a function value corresponding to the method
 // of v with the given name.
 // The arguments to a Call on the returned function should not include