Skip to content

Instantly share code, notes, and snippets.

@dora-gt
Created January 27, 2022 02:08
Show Gist options
  • Save dora-gt/eae6e5ee785c231ecb95a24000dbd87e to your computer and use it in GitHub Desktop.
Save dora-gt/eae6e5ee785c231ecb95a24000dbd87e to your computer and use it in GitHub Desktop.
returning from a block
def do_something(&block)
    puts "(1)"
    yield block
    puts "(2)"
end

def do_this
    puts "(3)"
    do_something do
        puts "(4)"
        next
        puts "(5)"
    end
    puts "(6)"
end

do_this

outputs

(3)
(1)
(4)
(2)
(6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment