Project

General

Profile

Actions

Feature #11129

open

block-level hash destructuring only works for the last argument

Added by seanlinsley (Sean Linsley) over 9 years ago. Updated over 5 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:69094]

Description

[{a: 2}].each_with_index{ |a:, index| }
SyntaxError: unexpected tIDENTIFIER

[{a: 2}].each_with_index{ |(a:), index| }
SyntaxError: unexpected tLABEL

[{a: 2}].each_with_index.map{ |hash, index| [index, hash] }.map{ |index, a:| p [index, a] }
== [0, 2]

It seems like the second example should work, in the same way that parentheses in || destructure arrays.

Updated by seanlinsley (Sean Linsley) over 9 years ago

I'd rename this bug to something like "block-level hash destructuring only works for the last argument" if Redmine let you rename bugs...

Updated by hsbt (Hiroshi SHIBATA) over 9 years ago

  • Subject changed from each_with_index doesn't work with block-level hash destructuring to block-level hash destructuring only works for the last argument
Actions #3

Updated by jeremyevans0 (Jeremy Evans) over 5 years ago

  • Tracker changed from Bug to Feature
  • ruby -v deleted (2.2)
  • Backport deleted (2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0