Issue #10837 has been updated by bug hit.


Naja Melan wrote:
> 
> 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.

This is a bad hack that produces obfuscated code and does not work properly, if you splat a hash you will end up with an array of arrays.  What you want is something like Array.wrap from rails, which both communicates intention clearly and works universally.

Splatting an array should consistently destructure it.

----------------------------------------
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-59642

* 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>