Project

General

Profile

Feature #11129

block-level hash destructuring only works for the last argument

Added by seanlinsley (Sean Linsley) almost 6 years ago. Updated over 1 year ago.

Status:
Open
Priority:
Normal
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.

Also available in: Atom PDF