[#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:76394] [Ruby trunk Bug#10837] spatting a single element array produces an array instead of a single value for return and next
From:
najamelan@...
Date:
2016-07-18 12:47:51 UTC
List:
ruby-core #76394
Issue #10837 has been updated by Naja Melan.
bug hit wrote:
> Nobuyoshi Nakada wrote:
> > It's similar to `return *[1, 2]`.
>
> Please clarify your position, is this about preserving compatibility, or do you really disagree that conceptually an rvalue splat should eliminate the array?
Actually this is really useful. Whenever a method accepts a `something` or an `array of somethings` you can use the splat operator to make it an array if it's not already. Now you can operate on it as an array.
~~~ ruby
def initialize( something )
@something = *something
end
~~~
If it didn't do that, you would have to write:
~~~ ruby
@something = something.kind_of?( Array ) ? something : [something]
~~~
----------------------------------------
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-59639
* 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>