> /opt/ruby-1.9.1/bin/irb
irb(main):001:0> def sample_method(a, b=0, *c, &d);end
=> nil
irb(main):002:0> self.method(:sample_method).parameters
=> [[:req, :a], [:opt, :b], [:rest, :c], [:block, :d]]
As you see, Method#parameters returns 2-dimensional array, not hash.
In each inner array, the first is parameter type and the last is parameter name. Parameter type is represented by symbol; :req is normal parameter, :opt is parameter with default value, :rest is variable parameter, and :block is block parameter.
2 comments:
this is not there in ruby-1.9.2 ?
No, still in there. I check to work above irb samples
Post a Comment