Actions
Bug #11160
closedSubclasses of Proc converted when passed to a block
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
Description
As Subclasses of Proc are passed as-is when sent to methods as blocks, it would be expected that the same behavior occurs when passing such a subclass of Proc to a block. However, Ruby's block.call somehow converts the block to a Proc, losing the passed subclass. Is this a bug, or is there a particular reason for this design?
Here is an example:
class MyClass < Proc
end
=> nil
def foo (&x)
p x.class
end
=> :foo
x = Proc.new {|&x| p x.class}
=> #Proc:0x007faf0b042f60@(irb):77
z = MyClass.new {}
=> #MyClass:0x007faf0b0393c0@(irb):78
foo &z
MyClass
=> MyClass
x.call &z
Proc
=> Proc
Actions
Like0
Like0