当我想用双splats等挖掘额外的参数时,我经常忘记新的关键字参数的语法。在线Ruby文档包含http://ruby-doc.org/core-2.1.0/doc/syntax/methods_rdoc.html和http://ruby-doc.org/core-2.0.0/doc/syntax/calling_methods_rdoc.html等文章,但我如何通过ri
访问此信息?
或者是ri
(正如交互模式的问题所暗示的那样“输入你要查找的方法名称”)它会找到的唯一一种东西?
非常感谢任何帮助或见解。
答案 0 :(得分:3)
您可以通过以下方式访问静态页面:
$ ri ruby:syntax/methods
输出:
= Methods
Methods implement the functionality of your program. Here is a simple method
definition:
def one_plus_one
1 + 1
end
A method definition consists of the def keyword, a method name, the body of
the method, return value and the end keyword. When called the method will
execute the body of the method. This method returns 2.
This section only covers defining methods. See also the {syntax documentation
on calling methods}[rdoc-ref:syntax/calling_methods.rdoc].
[...]