Project

General

Profile

Actions

Feature #9095

open

Allow `Symbol#to_proc` to take arguments

Added by alexeymuranov (Alexey Muranov) over 10 years ago. Updated over 10 years ago.

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

Description

=begin
After discussing #9076, i've decided to propose this:

class Symbol
def to_proc(*args)
proc do |x|
x.public_send(self, *args)
end
end
end

p = :+.to_proc(1)

p[2] # => 3

[1, 2, 3, 4].map &:to_s.to_proc(2) #=> ["1", "10", "11", "100"]

This would allow constructing more kinds of procs without using literal blocks.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0