From: koen@... Date: 2018-09-21T19:27:36+00:00 Subject: [ruby-core:89122] [Ruby trunk Bug#15145] chained mappings proposal Issue #15145 has been reported by koenhandekyn (koen handekyn). ---------------------------------------- Bug #15145: chained mappings proposal https://bugs.ruby-lang.org/issues/15145 * Author: koenhandekyn (koen handekyn) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- 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 as 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) ~~~ ruby collection.map(&:instrument).map(&:issuer).map(&:name) ~~~ equivalent to ~~~ ruby collection.map { |e| e&.instrument }.map { |e| e&.issuer }.map { |e| e&.name } ~~~ proposal allow ~~~ ruby collection.map(&:instrument, &:issuer, &:name) ~~~ implementation is trivial -- https://bugs.ruby-lang.org/ Unsubscribe: