Ruby / IRB自助 [英] Ruby/IRB self help
问题描述
我是Ruby的新手 - 我可以使用什么技巧来帮助我找到我正在使用的对象的文档?通常我只是做 a_var.class
或 a_var.methods
,并尝试猜测我需要什么或在网上搜索文档。有没有其他方法或模块可能有帮助?
I'm new to Ruby - what tricks can I use to help me find documentation on a object I'm working with? Normally I just do a_var.class
or a_var.methods
and try to guess what I need or search the web for documentation. Are there other methods or modules that might help?
推荐答案
只要您安装了安装Ruby的文档,可以输入 helpString
来显示例如 String
类的文档。或者您可以键入 help obj.Class
来实现相同的效果。
As long as you have the documentation installed for your installation of Ruby, you can type help "String"
to show the documentation for the String
class, for instance. Or you can type help obj.Class
to achieve the same effect.
有关实例方法的文档,语法是 Class#方法
;和 Class :: method
用于类方法。也就是说, helpString#chop
或 helpString :: new
将会弹出相应的文件。
For documentation on instance methods, the syntax is Class#method
; and Class::method
for class methods. That is to say, help "String#chop"
or help "String::new"
will bring up the respective documentation.
这篇关于Ruby / IRB自助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!