I see in the Ruby documentation for 1.9.2 that there is:
meth.parameters → array
returns the parameter information of this method
For class UnboundMethod.
http://www.ruby-doc.org/core/classes/UnboundMethod.html
Does anyone know how to do so in Ruby 1.8.7 ?
I lately wanted to get all parameters to a method, but without using a
hash. (With a hash, it is easy.)
def foo(a, b = ‘foo’,c = ‘bar’, d = ‘faa’)
puts ‘Hello from method foo. Try to find out my parameters!’
end
method(:foo).parameters
If this is not possible in Ruby 1.8.7 I may have found another reason to
finally switch to 1.9.x even though the Encoding issues are annoying to
deal with for me in 1.9.x (1.8.x gives me no problem here).