From: jgomo3@... Date: 2020-03-03T13:37:30+00:00 Subject: [ruby-core:97341] [Ruby master Feature#16667] Allow parameters to Symbol#to_proc and Method#to_proc Issue #16667 has been updated by jgomo3 (Jes�s G�mez). Hanmac (Hans Mackowiak) wrote in #note-5: > i tried `ary.map.with_object(:id,&:dig)` but it just returned `:id` > > but this one would work: `ary.each_with_object(:id).map(&:dig)` Amazing this approach. Sadly, it will work only for Arity-1 functions. If you want to dig more, how to do it? e.g, supposing `to_proc` supports this idea: ``` ary = [{thing: {id: 1, v:3}, meta: {}}, {thing: {id: 2, v: 4}, meta:{}}] ary.map(&:dig.to_proc(:thing, :id)) # [1, 2] ``` ---------------------------------------- Feature #16667: Allow parameters to Symbol#to_proc and Method#to_proc https://bugs.ruby-lang.org/issues/16667#change-84462 * Author: jgomo3 (Jes�s G�mez) * Status: Open * Priority: Normal ---------------------------------------- Allow parameters to Symbol#to_proc and Method#to_proc So we can say: ``` ruby ary.map(:dig.to_proc(:id)) ``` Instead of ``` ruby ary.map { |e| e.dig(:id) } ``` Oppening the posibilities to refine the `&` operator in the future, for something like: ``` ruby ary.map(&(:dig, :id)) ``` Related: * https://bugs.ruby-lang.org/issues/11161 * https://bugs.ruby-lang.org/issues/16435 -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>