P
Patrick Li
class A
def A.method &block
A.new.instance_eval &block
end
def A.method2 &block
A.new.instance_eval {block.call}
end
end
A.method{p self} #prints #<A:0x28c2858>
A.method2{p self} #prints main
From this example: is instance_eval even working in method2? It clearly
shows that block is not called in A's context.
-Patrick
def A.method &block
A.new.instance_eval &block
end
def A.method2 &block
A.new.instance_eval {block.call}
end
end
A.method{p self} #prints #<A:0x28c2858>
A.method2{p self} #prints main
From this example: is instance_eval even working in method2? It clearly
shows that block is not called in A's context.
-Patrick