Project

General

Profile

Actions

Feature #15145

open

chained mappings proposal

Added by koenhandekyn (koen handekyn) about 6 years ago. Updated about 6 years ago.

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

Description

propsal, have map accept array of method references to make chained mapping simpler with suggestion to implement it to behave like the &. operator so that intermediate nil values just ripple through as nil values

proposal allow

collection.map(&:instrument, &:issuer, &:name)

implementation is trivial

this as a conceptual alternative to (with important remark is that if first or second mapping returns nil values the above code will break, forcing a much more verbose notation)

collection.map(&:instrument).map(&:issuer).map(&:name)

proposal to be functional equivalent to

collection.map { |e| e&.instrument }.map { |e| e&.issuer }.map { |e| e&.name }
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0