1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* doc/syntax/assignment.rdoc (Implicit Array Assignment): Clarify

that "left-hand side" means "of the assignment".  Suggested by Jorge
  Dias.
* doc/syntax/assignment.rdoc (Multiple Assignment):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2013-01-23 01:41:37 +00:00
parent 2784129653
commit 596ed9c781
2 changed files with 12 additions and 4 deletions

View file

@ -1,3 +1,10 @@
Wed Jan 23 10:40:49 2013 Eric Hodel <drbrain@segment7.net>
* doc/syntax/assignment.rdoc (Implicit Array Assignment): Clarify
that "left-hand side" means "of the assignment". Suggested by Jorge
Dias.
* doc/syntax/assignment.rdoc (Multiple Assignment): ditto.
Wed Jan 23 10:34:47 2013 Eric Hodel <drbrain@segment7.net> Wed Jan 23 10:34:47 2013 Eric Hodel <drbrain@segment7.net>
* doc/syntax/assignment.rdoc (Local Variables and Methods): Fixed * doc/syntax/assignment.rdoc (Local Variables and Methods): Fixed

View file

@ -374,7 +374,7 @@ assigning. This is similar to multiple assignment:
p a # prints [1, 2, 3] p a # prints [1, 2, 3]
You can splat anywhere in the left-hand side: You can splat anywhere in the left-hand side of the assignment:
a = 1, *[2, 3] a = 1, *[2, 3]
@ -408,14 +408,15 @@ You can use multiple assignment to swap two values in-place:
p new_value: new_value, old_value: old_value p new_value: new_value, old_value: old_value
# prints {:new_value=>1, :old_value=>2} # prints {:new_value=>1, :old_value=>2}
If you have more values on the left hand side than variables on the right hand If you have more values on the left hand side of the assignment than variables
side the extra values are ignored: on the right hand side the extra values are ignored:
a, b = 1, 2, 3 a, b = 1, 2, 3
p a: a, b: b # prints {:a=>1, :b=>2} p a: a, b: b # prints {:a=>1, :b=>2}
You can use <code>*</code> to gather extra values on the right-hand side. You can use <code>*</code> to gather extra values on the right-hand side of
the assignment.
a, *b = 1, 2, 3 a, *b = 1, 2, 3