Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: