Search code examples
rubydocumentationri

Where are the keyword method arguments documented in ri?


I often forget the syntax for the newer keyword arguments when I want to scoop up extra arguments with double splats and the like. The online Ruby docs has articles such as http://ruby-doc.org/core-2.1.0/doc/syntax/methods_rdoc.html and http://ruby-doc.org/core-2.0.0/doc/syntax/calling_methods_rdoc.html, but how could I access this info via ri?

Or is ri (as implied by the interactive mode's question "Enter the method name you want to look up") the only sort of thing it will find?


Solution

  • You can access the static pages via:

    $ ri ruby:syntax/methods
    

    Output:

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