【问题标题】:Where are the keyword method arguments documented in ri? [closed]ri 中记录的关键字方法参数在哪里? [关闭]
【发布时间】:2017-08-16 11:00:04
【问题描述】:

当我想用双 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(正如交互模式的问题“输入您要查找的方法名称”所暗示的那样)是它唯一能找到的东西?

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

【问题讨论】:

  • 你是第一个使用 ri 的 ruby​​ 开发者(据我所知):)
  • 忘记语法是什么意思?这个SO Post 对参数顺序有很好的解释(也许只是书签)
  • @SergioTulentsev 我是我认识的最矛盾的人,所以这并不奇怪! :)
  • @engineersmnky 事情的顺序当我想把东西吸起来时,除了逻辑,我尽量不要在脑海中保留任何东西:-) Ta 的链接,这很有帮助。
  • NP 虽然逻辑表明记住语法很重要

标签: ruby documentation ri


【解决方案1】:

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

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

[...]

【讨论】:

  • 啊! ri ruby:syntax 也带来了一种菜单页面,以防我忘记了methods 部分(我会忘记的:)。非常好,谢谢。
  • 谢谢。我一直在搜索各种 ri/rdoc 文档/教程/帮助页面,但我认为我没有在任何地方看到过这个(即使用 ruby: 前缀)。
  • @doubleDown 前缀选择一个通常是 gem 的 rdoc 数据存储。 RDoc::Store#source 的文档提到它也可以是“home”、“site”和“ruby”。
  • @iain 还有ri ruby:,它将列出所有 ruby​​ 核心页面。
猜你喜欢
  • 2013-02-21
  • 2013-05-25
  • 1970-01-01
  • 2011-04-15
  • 2011-04-03
  • 2013-10-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多