4 Matching Annotations
- Feb 2020
-
blog.saeloun.com blog.saeloun.com
-
The rules for finding the arity of the methods are as follows:
-
-
The **nil argument was added in Ruby 2.7 to explicity mark that the method accepts no keyword arguments.
-
-
ruby-doc.org ruby-doc.org
-
Returns an indication of the number of arguments accepted by a method. Returns a nonnegative integer for methods that take a fixed number of arguments. For Ruby methods that take a variable number of arguments, returns -n-1, where n is the number of required arguments. Keyword arguments will be considered as a single additional argument, that argument being mandatory if any keyword argument is mandatory. For methods written in C, returns -1 if the call takes a variable number of arguments.
What they fail to mention is that apparently the arity is always -1 if the method is available dynamically (due to
respond_to_missing?
).
Tags
Annotators
URL
-