Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get method signatures or method descriptions in Ruby's irb?

Tags:

ruby

irb

I'm wondering if Ruby's irb has the ability to supply method/function signatures or descriptions.

I know I can do something like this in the irb

[].methods.sort

and get all the methods/functions available to arrays but how can I get more information(while in the irb) about specific methods/functions?


1 Answers

You can use #method and then use Method methods:

1.method(:+).arity
# => 1
1.method(:+).parameters
# => [[:req]]
[].method(:reduce).parameters
# => [[:rest]]

like image 76
mrzasa Avatar answered Oct 18 '25 12:10

mrzasa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!