< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #10837 has been updated by bug hit.
bug hit wrote:
> Nobuyoshi Nakada wrote:
> > It's similar to `return *[1, 2]`.
>
> No it's not similar,
>
> `return *[1, 2]` means `return 1, 2`
>
> similar would be:
>
> `return *[1]` means `return 1`
>
> in general, splatting in a context that takes a coma separated list of items (method args, rescue, return, next, multiple assignment) is supposed to destructure the array. The array should be gone, only the elemnts remain, so returning the `[1]` is wrong.
some examples
`method_call *[a]` is `method_call a` as expected
`rescue *[a]` is `rescue a` as expected
`[*[a]]` is `[a]` as expected
`b = *[a]` is `b = [a]` why?
`(next|return) *[a]` is `(next|return) [a]` why?
the intuitive, expected and logical behavior would be for `*array` to consistently destructure, when used in a coma separated list context
----------------------------------------
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-51449
* 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/