Skip to content

Instantly share code, notes, and snippets.

@jc00ke
Forked from timfel/gist:1439913
Created December 6, 2011 21:04
Show Gist options
  • Save jc00ke/1439994 to your computer and use it in GitHub Desktop.
Save jc00ke/1439994 to your computer and use it in GitHub Desktop.
Want to look at the code a block would run when called?
~ maglev ✔ maglev-irb -f
irb(main):001:0> b = proc { p 1 }
=> #<Proc>
irb(main):002:0> b.instance_variable_get("@_st_block")
=> #<ExecBlock:0x561a6201
irb(main):003:0> block = b.instance_variable_get("@_st_block")
=> #<ExecBlock:0x561a6201
irb(main):004:0> block.class
=> ExecBlock
irb(main):005:0> block.class.primitive '_sourceString', '_sourceString'
=> ExecBlock
irb(main):006:0> block._sourceString
=> "\"This is source for a block. \" \n ^ { p 1 }"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment