diff options
author | zverok <zverok.offline@gmail.com> | 2019-12-21 22:31:30 +0200 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-12-22 23:17:39 +0900 |
commit | 5fa9c2eeb04a2e44a2a028d933bc95f219a6a282 (patch) | |
tree | 3e9f01f94174cbdfd1210d87f7af04547fd6d678 /proc.c | |
parent | d78fcfb7ab351fd4861e42985db34e9bda3509a7 (diff) |
Actualize Method#inspect docs
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2768
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -2766,11 +2766,30 @@ rb_method_parameters(VALUE method) * * Returns a human-readable description of the underlying method. * - * "cat".method(:count).inspect #=> "#<Method: String#count>" - * (1..3).method(:map).inspect #=> "#<Method: Range(Enumerable)#map>" + * "cat".method(:count).inspect #=> "#<Method: String#count(*)>" + * (1..3).method(:map).inspect #=> "#<Method: Range(Enumerable)#map()>" * * In the latter case, the method description includes the "owner" of the * original method (+Enumerable+ module, which is included into +Range+). + * + * +inspect+ also provides, when possible, method argument names (call + * sequence) and source location. + * + * require 'net/http' + * Net::HTTP.method(:get).inspect + * #=> "#<Method: Net::HTTP.get(uri_or_host, path=..., port=...) <skip>/lib/ruby/2.7.0/net/http.rb:457>" + * + * <code>...</code> in argument definition means argument is optional (has + * some default value). + * + * For methods defined in C (language core and extensions), location and + * argument names can't be extracted, and only generic information is provided + * in form of <code>*</code> (any number of arguments) or <code>_</code> (some + * positional argument). + * + * "cat".method(:count).inspect #=> "#<Method: String#count(*)>" + * "cat".method(:+).inspect #=> "#<Method: String#+(_)>"" + */ static VALUE |