Ruby 相当于 Python 的 help()? [英] Ruby equivalent to Python's help()?
问题描述
在交互式 Python 中工作时,我倾向于依赖内置的 help()
函数来告诉我期望和/或返回什么,并打印出任何可能对我有帮助的文档.是否有与此功能等效的 Ruby?
我正在寻找可以在 irb 中使用的东西.例如,在交互式 Python 中,我可以输入:
<预><代码>>>>帮助(1)然后打印
关于 int 对象的帮助:类 int(object) |int(x[, 基数])->整数 ||如果可能,将字符串或数字转换为整数.一种 ...
它绝对是 iPython 的帮凶,也是我迁移到 Ruby 后怀念的主要功能之一,但您也可以使用 ri
来自 irb
.我建议使用 wirble gem 作为一种简单的设置方法.
When working in interactive Python, I tend to rely on the built-in help()
function to tell me what something expects and/or returns, and print out any documentation that might help me. Is there a Ruby equivalent to this function?
I'm looking for something I could use in irb. For example, in interactive Python I could type:
>>> help(1)
which would then print
Help on int object:
class int(object) | int(x[, base])
-> integer | |
Convert a string or number to an integer, if possible. A ...
It's definitely a poor cousin to iPython's help, and one of the main features I miss after moving to Ruby, but you can also use ri
from within irb
. I'd recommend the wirble gem as an easy way to set this up.
这篇关于Ruby 相当于 Python 的 help()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!