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=3D obj
      @args=3Dargs
      @methId=3DmethId
    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(@methI=
d,*@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)) #=3D> ["1", "10", "11", "100"]
[1,2,3,4].map(&:to_s.(2).length) #=3D> [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=FAs G=F3mez)
* 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 som=
ething 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=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>