From: Rob Pike Date: Thu, 14 Jul 2011 00:38:15 +0000 (+1000) Subject: reflect: trivial addition: Value.NumMethod. X-Git-Tag: weekly.2011-07-19~71 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=125e8277d57cb98d1342687fd0468d6aa50c05d2;p=gostls13.git reflect: trivial addition: Value.NumMethod. Just an oversight it was missing. R=rsc, dsymonds, bradfitz, r CC=golang-dev https://golang.org/cl/4695059 --- diff --git a/src/pkg/reflect/value.go b/src/pkg/reflect/value.go index bfeb3267c7..82985c5751 100644 --- a/src/pkg/reflect/value.go +++ b/src/pkg/reflect/value.go @@ -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