diff options
Diffstat (limited to 'doc/syntax/calling_methods.rdoc')
| -rw-r--r-- | doc/syntax/calling_methods.rdoc | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/doc/syntax/calling_methods.rdoc b/doc/syntax/calling_methods.rdoc index 63a1b43781..a24c5fbf1f 100644 --- a/doc/syntax/calling_methods.rdoc +++ b/doc/syntax/calling_methods.rdoc @@ -291,14 +291,14 @@ override local arguments outside the block in the caller's scope: This prints: hello main this is block - place is world + place is: world So the +place+ variable in the block is not the same +place+ variable as outside the block. Removing <code>; place</code> from the block arguments gives this result: hello main this is block - place is block + place is: block === Unpacking Positional Arguments @@ -355,9 +355,8 @@ as one argument: # Prints the object itself: # #<Name:0x00007f9d07bca650 @name="Jane Doe"> -This allows to handle one or many arguments polymorphically. Note also that +nil+ -has NilClass#to_a defined to return an empty array, so conditional unpacking is -possible: +This allows to handle one or many arguments polymorphically. Note also that <tt>*nil</tt> +is unpacked to an empty list of arguments, so conditional unpacking is possible: my_method(*(some_arguments if some_condition?)) @@ -426,7 +425,7 @@ as keyword arguments: name = Name.new('Jane Doe') p(**name) - # Prints: {name: "Jane", last: "Doe"} + # Prints: {first: "Jane", last: "Doe"} Unlike <code>*</code> operator, <code>**</code> raises an error when used on an object that doesn't respond to <code>#to_hash</code>. The one exception is |
