代码之家  ›  专栏  ›  技术社区  ›  ian

ri中记录的关键字方法参数在哪里?[已关闭]

  •  3
  • ian  · 技术社区  · 7 年前

    当我想用双splat之类的工具收集额外的参数时,我经常忘记新的关键字参数的语法。在线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

    或者是 (正如交互模式的问题“输入要查找的方法名”所暗示的那样)它将找到的唯一一种东西?

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

    1 回复  |  直到 7 年前
        1
  •  3
  •   Stefan    7 年前

    您可以通过以下方式访问静态页面:

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