summaryrefslogtreecommitdiff
path: root/vm_eval.c
diff options
context:
space:
mode:
authorOKURA Masafumi <masafumi.o1988@gmail.com>2019-08-16 22:56:30 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-08-17 12:19:13 +0900
commit042be439d92ea0910fe3bd0d5e9a1d4135257d2d (patch)
tree85dca40985a6b888dcf7981e2d05674c8f8ba9b0 /vm_eval.c
parent045152df9e91c34a2785cb95e5964d7fc1b14df5 (diff)
Improve the doc example of `method_missing`
Improvements are: * Use `symbol` instead of `methId`, described in doc * Add `*args` following method signature * Rescue error in `roman_to_int` and calls `super`, recommended in doc * Call invalid `foo` method to Roman object to raise NoMethodError
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2372
Diffstat (limited to 'vm_eval.c')
-rw-r--r--vm_eval.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/vm_eval.c b/vm_eval.c
index 222389ec08..a0f8e55f5d 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -634,9 +634,14 @@ NORETURN(static void raise_method_missing(rb_execution_context_t *ec, int argc,
* def roman_to_int(str)
* # ...
* end
- * def method_missing(methId)
- * str = methId.id2name
- * roman_to_int(str)
+ *
+ * def method_missing(symbol, *args)
+ * str = symbol.id2name
+ * begin
+ * roman_to_int(str)
+ * rescue
+ * super(symbol, *args)
+ * end
* end
* end
*
@@ -644,6 +649,7 @@ NORETURN(static void raise_method_missing(rb_execution_context_t *ec, int argc,
* r.iv #=> 4
* r.xxiii #=> 23
* r.mm #=> 2000
+ * r.foo #=> NoMethodError
*/
static VALUE