3 ms·
Nah. Ruby just raises an exception in this case: class BlockInvoker def initialize(&block) @block = block end def invoke @block.call
by wycats 15y ago
Nah. Ruby just raises an exception in this case:
class BlockInvoker
def initialize(&block)
@block = block
end
def invoke
@block.call
end
end
BlockInvoker.new { puts 1 }.invoke
def get_block_invoker
BlockInvoker.new { return }
end
get_block_invoker.invoke
I tried to cover this a bit in my post. For callbacks, this semantic is clunkier.