From 9da4dfb62a17b200eaaff458aec3edcba5255f9c Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 10 Sep 2016 08:16:50 +0000 Subject: extension.rdoc: rb_check_arity [ci skip] * doc/extension.rdoc (rb_check_arity): described. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- doc/extension.rdoc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/extension.rdoc b/doc/extension.rdoc index 28052708e2..7eb173debe 100644 --- a/doc/extension.rdoc +++ b/doc/extension.rdoc @@ -867,6 +867,9 @@ arguments. The third argument is a string that specifies how to capture method arguments and assign them to the following VALUE references. +You can just check the argument number with rb_check_arity(), this is +handy in the case you want to treat the arguments as a list. + The following is an example of a method that takes arguments by Ruby's array: @@ -1360,6 +1363,12 @@ rb_define_singleton_method(VALUE klass, const char *name, VALUE (*func)(), int a Defines a singleton method. Arguments are same as rb_define_method(). +rb_check_arity(int argc, int min, int max) :: + + Check the number of arguments, argc is in the range of min..max. If + max is UNLIMITED_ARGUMENTS, upper bound is not checked. If argc is + out of bounds, an ArgumentError will be raised. + rb_scan_args(int argc, VALUE *argv, const char *fmt, ...) :: Retrieve argument from argc and argv to given VALUE references -- cgit v1.2.3