From: hanmac@... Date: 2020-03-03T14:27:15+00:00 Subject: [ruby-core:97342] [Ruby master Feature#16667] Allow parameters to Symbol#to_proc and Method#to_proc Issue #16667 has been updated by Hanmac (Hans Mackowiak). @jgomo3 i found my old Symbol#call code ~~~ ruby class Symbol class SymbolHelper def initialize(obj,methId,*args) @obj= obj @args=args @methId=methId end def method_missing(methId,*args) return SymbolHelper.new(self,methId,*args) end def to_proc proc {|obj| (@obj.nil? ? obj : @obj.to_proc.(obj)).public_send(@methId,*@args) } end end def call(*args) return SymbolHelper.new(nil,self,*args) end end ~~~ you can chain it like that ~~~ ruby [1,2,3,4].map(&:to_s.(2)) #=> ["1", "10", "11", "100"] [1,2,3,4].map(&:to_s.(2).length) #=> [1, 2, 2, 3] ~~~ might be updated for keyword arguments ---------------------------------------- Feature #16667: Allow parameters to Symbol#to_proc and Method#to_proc https://bugs.ruby-lang.org/issues/16667#change-84463 * 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: