5 ms·
Doing the same with pry ALL THE TIME. It basically became my standard programming workflow. Especially you can also do `ls` to inspect objects and classes. Is
by roboben 3y ago
Doing the same with pry ALL THE TIME. It basically became my standard programming workflow. Especially you can also do `ls` to inspect objects and classes.
Is there any other language which can do that? And I don’t mean unergonomic debuggers.
- ysavir 3y agoAnother wonderful helper in Pry is `show-method`. If you type in `show-method Foo.bar`, it will pull up the source code for that method, or class, or whatever you pass to it. Great for looking something up when you don't understand what's going on behind the scenes, especially since it works on code from gems as well.
- corytheboyd 3y agoThis is such an amazing pry feature that I never see people use, excellent time saver
- ysavir 3y agoI also sometimes use it to then open the gem source code and insert a `binding.pry` to debug but that's... uh... not something I'd really endorse.
- corytheboyd 3y agoI’ve been there too, just don’t forget to remove it! Also would never tell anyone else to do this, unless I trust them not to come to me about “everything getting all weird”
- Linell 3y agoAnother pro-tip in this vein is `object.methods` to see a list of the methods to which the object you're messing with will respond. I use this all of the time when I'm diving into something trying to figure out what's going on.
- werdnapk 3y agoI always do object.methods.sort, otherwise my brain can't consume it
- vidarh 3y agoPry appears largely inspired by Smalltalk, which Ruby itself also draws heavily on, and which if anything can go much further.