In ruby, is there a way to know in the console what a method does?

后端 未结 2 2012
死守一世寂寞
死守一世寂寞 2021-01-27 13:07

In Ruby, if i am looking for the methods of a class. ie:String.methods.sort and i have the following:

[:!, :!=, :!~, :<, :<=, :<=>, :==,         


        
2条回答
  •  野性不改
    2021-01-27 13:59

    You can use

    help 'String#display'
    

    and it'll show the rdoc for the method (the same output that would show from running ri 'String#display' outside of irb. You can also just type help into irb and it'll go into a mode where you can just keep typing method names and it'll show the rdoc (enter a blank line to exit).

提交回复
热议问题