[#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:76402] [Ruby trunk Bug#10837] spatting a single element array produces an array instead of a single value for return and next
From:
alxtskrnk@...
Date:
2016-07-18 18:06:40 UTC
List:
ruby-core #76402
Issue #10837 has been updated by bug hit.
Naja Melan wrote:
> @bug hit
>
> My apologies, it seems I'm mistaken. The splat operator does not just seem to coerce into array for all types:
>
> ~~~ ruby
> a = { a: 1 }
>
> p [a] # [{:a=>1}]
> p *a # [:a, 1]
> p [*a] # [[:a, 1]]
> ~~~
>
> It seems it calls `#to_a` on classes that implement this. I'm sorry if I create confusion in the ongoing discussion.
Also when it's already an array (a = *array), what you are asking ruby to do is first destructure the array, then coalesce it back into an array, essentially making a shallow copy, whereas what you actually want is to leave it alone. Array.wrap leaves it alone.
----------------------------------------
Bug #10837: spatting a single element array produces an array instead of a single value for return and next
https://bugs.ruby-lang.org/issues/10837#change-59644
* Author: bug hit
* Status: Rejected
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
irb(main):013:0> ->{return *[1]}.()
=> [1]
irb(main):014:0> ->{next *[1]}.()
=> [1]
______________
*[x] should mean x as it already does for arguments
--
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>