[#76442] [Ruby trunk Feature#11741] Migrate Ruby to Git from Subversion — naruse@...
Issue #11741 has been updated by Yui NARUSE.
3 messages
2016/07/19
[#76515] [Ruby trunk Bug#12610] webrick: protect from httpoxy — nagachika00@...
Issue #12610 has been updated by Tomoyuki Chikanaga.
3 messages
2016/07/22
[ruby-core:76395] [Ruby trunk Feature#12593] Allow compound assignements to work when destructuring arrays
From:
najamelan@...
Date:
2016-07-18 12:59:58 UTC
List:
ruby-core #76395
Issue #12593 has been reported by Naja Melan.
----------------------------------------
Feature #12593: Allow compound assignements to work when destructuring arrays
https://bugs.ruby-lang.org/issues/12593
* Author: Naja Melan
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
~~~ ruby
a = [ 'a', 'b' ]
b = [ 'c', 'd' ]
def c
return [ 'A', 'B' ], [ 'C', 'D' ]
end
a, b += c # -> would be awesome, but gives syntax error
a, b = a + c.first, b + c.last # clunky and will call method twice...
# current realistic use:
t, tt = c
a += t
b += tt
# desired result
#
p a == [ 'a', 'c', 'A', 'B' ] #-> true
p b == [ 'b', 'd', 'C', 'D' ] #-> true
~~~
I would propose that as
~~~ ruby
a, b = [ c, d ] # is equivalent to:
a = c
b = d
a, b += [ c, d ] # would be equivalent to:
a += c
b += d
~~~
This not working surprised me. It could work with all compound assignment operators I think. Maybe even with some other operators.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>