Skip to content

Instantly share code, notes, and snippets.

@dragonfax
Created March 8, 2013 01:03
Show Gist options
  • Save dragonfax/5113407 to your computer and use it in GitHub Desktop.
Save dragonfax/5113407 to your computer and use it in GitHub Desktop.
nesting pry, event inside a block

Nesting pry works beautifully. Kudos to the pry team.

Nesting pry: (note the 2 exit statements needed)

Hershwild:~ jstillwell$ pry
[1] pry(main)> binding.pry
[1] pry(main)> exit
=> nil
[2] pry(main)> exit
Hershwild:~ jstillwell$ 

Bringing forth pry from within a block:

Hershwild:~ jstillwell$ pry
[1] pry(main)> def test
[1] pry(main)*   yield true
[1] pry(main)* end  
=> nil
[2] pry(main)> test do |inside|
[2] pry(main)*   binding.pry
[2] pry(main)* end  
# after that end statement, pry resumes inside the block
[1] pry(main)> inside
=> true
[2] pry(main)> exit
=> nil
[3] pry(main)> exit
Hershwild:~ jstillwell$ 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment