3

当我想用双 splats 之类的东西收集额外的参数时,我经常忘记更新关键字参数的语法。在线 Ruby 文档有http://ruby-doc.org/core-2.1.0/doc/syntax/methods_rdoc.htmlhttp://ruby-doc.org/core-2.0.0/doc/等文章syntax/calling_methods_rdoc.html,但我怎么能通过访问这些信息ri

还是ri(正如交互模式的问题“输入您要查找的方法名称”所暗示的那样)它会找到唯一的东西?

任何帮助或见解将不胜感激。

4

1 回答 1

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].

[...]
于 2017-08-16T13:38:31.093 回答