Skip to content

Instantly share code, notes, and snippets.

@hypomodern
Created May 24, 2012 20:11
Show Gist options
  • Save hypomodern/2783931 to your computer and use it in GitHub Desktop.
Save hypomodern/2783931 to your computer and use it in GitHub Desktop.
Blocks become of class Proc in a useful context ;)
class Proc
def foobar
puts "...method on Proc!"
end
end
def block_class &block
block.call
block.foobar
puts block.class.inspect
end
block_class { puts "I'm a..." }
# I'm a...
# method on Proc!
# Proc
@steveklabnik
Copy link

blocks are of type rb_block_t while procs are an rb_proc_t, which, as you can see, contains an rb_block_t.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment