Project

General

Profile

Actions

Feature #5766

closed

Hash.each_with_object should behave differently when block's arity is 3

Added by rosenfeld (Rodrigo Rosenfeld Rosas) over 12 years ago. Updated over 12 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:41668]

Description

Enum.each_with_object is very handy in lots of situations, but specially while dealing with arrays. It would be great to be able to use it with hashes like below:

{a: 1}.each_with_object([]){|k, v, object| ...}

Currently, we need to do

{a: 1}.each_with_object([]) do |pair, object|
k, v = pair
...
end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0