mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* doc/syntax/*.rdoc: separated modifier at sentence.
[ci skip][fix GH-1121] Patch by @clandry94 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b7d1536991
commit
4f94cb43fc
10 changed files with 50 additions and 53 deletions
|
@ -66,7 +66,7 @@ The positional arguments for the message follow the method name:
|
|||
|
||||
my_method(argument1, argument2)
|
||||
|
||||
In many cases parenthesis are not necessary when sending a message:
|
||||
In many cases, parenthesis are not necessary when sending a message:
|
||||
|
||||
my_method argument1, argument2
|
||||
|
||||
|
@ -88,7 +88,7 @@ hash-type arguments are assigned as a single hash to the last argument:
|
|||
|
||||
my_method('a' => 1, b: 2) # prints: {'a'=>1, :b=>2}
|
||||
|
||||
If too many positional arguments are given an ArgumentError is raised.
|
||||
If too many positional arguments are given, an ArgumentError is raised.
|
||||
|
||||
=== Default Positional Arguments
|
||||
|
||||
|
@ -250,8 +250,8 @@ Both are equivalent to:
|
|||
|
||||
my_method(1, 2, 3)
|
||||
|
||||
If the method accepts keyword arguments the splat operator will convert a hash
|
||||
at the end of the array into keyword arguments:
|
||||
If the method accepts keyword arguments, the splat operator will convert a
|
||||
hash at the end of the array into keyword arguments:
|
||||
|
||||
def my_method(a, b, c: 3)
|
||||
end
|
||||
|
@ -263,7 +263,7 @@ You may also use the <code>**</code> (described next) to convert a Hash into
|
|||
keyword arguments.
|
||||
|
||||
If the number of objects in the Array do not match the number of arguments for
|
||||
the method an ArgumentError will be raised.
|
||||
the method, an ArgumentError will be raised.
|
||||
|
||||
If the splat operator comes first in the call, parentheses must be used to
|
||||
avoid a warning.
|
||||
|
@ -290,7 +290,7 @@ Both are equivalent to:
|
|||
my_method(first: 3, second: 4, third: 5)
|
||||
|
||||
If the method definition uses <code>**</code> to gather arbitrary keyword
|
||||
arguments they will not be gathered by <code>*</code>:
|
||||
arguments, they will not be gathered by <code>*</code>:
|
||||
|
||||
def my_method(*a, **kw)
|
||||
p arguments: a, keywords: kw
|
||||
|
@ -302,7 +302,7 @@ Prints:
|
|||
|
||||
{:arguments=>[1, 2, {"3"=>4}], :keywords=>{:five=>6}}
|
||||
|
||||
Unlike the splat operator described above the <code>**</code> operator has no
|
||||
Unlike the splat operator described above, the <code>**</code> operator has no
|
||||
commonly recognized name.
|
||||
|
||||
=== Proc to Block Conversion
|
||||
|
@ -323,12 +323,12 @@ operator:
|
|||
If the splat operator comes first in the call, parenthesis must be used to
|
||||
avoid a warning.
|
||||
|
||||
Unlike the splat operator described above the <code>&</code> operator has no
|
||||
Unlike the splat operator described above, the <code>&</code> operator has no
|
||||
commonly recognized name.
|
||||
|
||||
== Method Lookup
|
||||
|
||||
When you send a message Ruby looks up the method that matches the name of the
|
||||
When you send a message, Ruby looks up the method that matches the name of the
|
||||
message for the receiver. Methods are stored in classes and modules so method
|
||||
lookup walks these, not the objects themselves.
|
||||
|
||||
|
@ -347,7 +347,6 @@ If no match is found this repeats from the beginning, but looking for
|
|||
+method_missing+. The default +method_missing+ is BasicObject#method_missing
|
||||
which raises a NameError when invoked.
|
||||
|
||||
If refinements (an experimental feature) are active the method lookup changes.
|
||||
If refinements (an experimental feature) are active, the method lookup changes.
|
||||
See the {refinements documentation}[rdoc-ref:syntax/refinements.rdoc] for
|
||||
details.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue