From: Roger Pack Date: 2009-12-16T00:30:34+09:00 Subject: Re: Introspecting Method Arguments with Method.arity > Documentation reveals that when a method has optional arguments, the > arity is -n - 1 where n is the number of required arguments (which > seems a little arbitrary, is there a historical reason for this?). I was reading something about this the other day in README.EXT -- its description of rb_define_method I think. Basically "-1 and -2 are magic numbers" denoting the type of argument your C method expects (an array or not). Something like that. > Is there a way to return the number of required arguments, the number > of optional arguments and whether or not a splat is present for a > method? arguments (or rdp-arguments gem) gems might be useful for you. [this snippet'll need to be in a file for 1.9] require 'rubygems' require 'arguments' class A def go a, b = 3, *args end end puts Arguments.names A, :go, false -- Posted via http://www.ruby-forum.com/.