Project

General

Profile

Bug #10277 ยป ampersand-to_proc.rb

jridgewell (Justin Ridgewell), 09/21/2014 10:26 PM

 
class AmpersandMethod
def mapper(*args)
'instance method'
end

def to_proc
method(:mapper)
end
end

class AmpersandMethodToProc
def mapper(*args)
'instance method'
end

def to_proc
method(:mapper).to_proc
end
end

def yielder
yield
end

a = [1]

# Works
puts yielder(&AmpersandMethod.new.method(:mapper))
puts a.map(&AmpersandMethod.new.method(:mapper))

# Works
puts yielder(&AmpersandMethodToProc.new)
puts a.map(&AmpersandMethodToProc.new)
puts yielder(&AmpersandMethodToProc.new)
puts a.map(&AmpersandMethodToProc.new)

# Errors
puts yielder(&AmpersandMethod.new)
puts a.map(&AmpersandMethod.new)
    (1-1/1)