From 2eee74ef54a2e23eb870680a83dcf74c5d9d9d01 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 29 Dec 2018 23:40:15 +0000 Subject: Update NoMethodError/NameError docs [ci skip] [ruby-core:90796] [Bug #15481] From: zverok (Victor Shepelev) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- error.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'error.c') diff --git a/error.c b/error.c index a085afd800..beae3b8138 100644 --- a/error.c +++ b/error.c @@ -1451,12 +1451,15 @@ name_err_init_attr(VALUE exc, VALUE recv, VALUE method) /* * call-seq: - * NameError.new(msg [, name]) -> name_error - * NameError.new(msg [, name], receiver:) -> name_error + * NameError.new(msg=nil, name=nil, receiver: nil) -> name_error * * Construct a new NameError exception. If given the name * parameter may subsequently be examined using the NameError#name - * method. + * method. receiver parameter allows to pass object in + * context of which the error happened. Example: + * + * [1, 2, 3].method(:rject) # NameError with name "rject" and receiver: Array + * [1, 2, 3].singleton_method(:rject) # NameError with name "rject" and receiver: [1, 2, 3] */ static VALUE @@ -1535,12 +1538,18 @@ nometh_err_init_attr(VALUE exc, VALUE args, int priv) /* * call-seq: - * NoMethodError.new([msg, *, name [, args [, priv]]]) -> no_method_error + * NoMethodError.new(msg=nil, name=nil, args=nil, private=false, receiver: nil) -> no_method_error * * Construct a NoMethodError exception for a method of the given name * called with the given arguments. The name may be accessed using * the #name method on the resulting object, and the * arguments using the #args method. + * + * If private argument were passed, it designates method was + * attempted to call in private context, and can be accessed with + * #private_call? method. + * + * receiver argument stores an object whose method was called. */ static VALUE -- cgit v1.2.3