Programming Ruby 3.2 (5th Edition): B2.0 page 469-472, switch parameter and argument


I am afraid the whole section Invoking a Method needs to switch parameter and argument.
Below I have copied the text, replacing parameter with ARGUMENT and argument with PARAMETER where a swith is needed.

Additional corrections are marked like this :

***** NOTE : xxx *****
Invoking a Method

‹ receiver. ›name‹ ARGUMENT › ‹ {block} ›
‹ receiver:: ›name‹ ARGUMENT › ‹ {block} ›
ARGUMENT ← ( ‹ARG›* ‹ , hashlist › ‹ array › ‹&a_proc › )
***** NOTE : also ‹param›
to be replaced by ‹arg›* *****
block ← { blockbody } or do blockbody end

The parentheses around the ARGUMENTS may be omitted if the expression is otherwise

Initial ARGUMENTS are assigned to the actual PARAMETERS of the method. Following these
ARGUMENTS may be a list of key: value pairs, which correspond to keyword PARAMETERS of
the method.

Any ARGUMENT may be a prefixed with an asterisk. If a starred ARGUMENT supports the to_a

***** NOTE : superfluous a *****

Any parameter may be a prefixed with an asterisk.
              -----> ^

method, that method is called, and the resulting array is expanded inline to provide
ARGUMENTS to the method call. If a starred argument does not support to_a, it is simply passed
through unaltered.

… code …

Any ARGUMENT may be prefixed with two asterisks (a double splat). Such ARGUMENTS are
treated as hashes, using to_hash to convert if the ARGUMENT is not a hash, and their key-value
pairs are added as additional keyword ARGUMENTS to the method call.

… code …

When a method defined with keyword PARAMETERS is called, Ruby matches the keys in the
passed hash with each PARAMETER, assigning values when it finds a match.

… code …

If the passed hash contains any keys not defined as PARAMETERS, Ruby raises a runtime error
unless the method also declares a double splat PARAMETER. In that case, the double splat
receives the excess key-value pairs from the passed hash. If the passed hash is missing keys
that are defined as required PARAMETERS without default values, Ruby raises a runtime error.

… code …

As with hash literals, if there is an existing local value with the same name as the keyword
argument, you can pass the argument without a value and the local value will be found and

x = 10
y = 5
foo(x:, y:)

A block may be associated with a method call using either a literal block (which must start
on the same source line as the last line of the method call) or AN ARGUMENT containing a reference
to a lambda, Proc, or Method object prefixed with an ampersand character. If the object
prefixed by a block responds to to_proc, then to_proc is invoked and the resulting proc passed

***** NOTE : twice the *****

to the the method.
   ^^^^^^^ <-----

… code …

Ruby sets the value of block_given? to reflect the availability of a block associated with the
call, regardless of the presence of a block PARAMETER. An explicit block PARAMETER will be set
to nil if no block is specified on the call to a method.

… code …

A method is called by passing … OK … and terminate the program.

When a receiver is explicitly specified in a method invocation, it may be separated from the
method name using either a period (.) or, much, much, much more rarely, two colons (::).
The only difference between these two forms occurs if the method name starts with an
uppercase letter. In this case, Ruby will assume that receiver::Thing is an attempt to access a
constant called Thing in the receiver unless the method invocation has AN ARGUMENT list between
parentheses. Using :: to indicate a method call is soft- deprecated, because of its potential
for confusion with constant access.

Yeah, I struggled with this because the existing text is as given, and I wasn’t sure I wanted to mess with the original, but the book is otherwise consistent that arguments are on the method call and parameters are in the method definition, so this should be as well.