mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 07:08:01 +00:00
Add Ins And Outs Of Pry as a ruby til
This commit is contained in:
@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
|
|||||||
For a steady stream of TILs from a variety of rocketeers, checkout
|
For a steady stream of TILs from a variety of rocketeers, checkout
|
||||||
[til.hashrocket.com](https://til.hashrocket.com/).
|
[til.hashrocket.com](https://til.hashrocket.com/).
|
||||||
|
|
||||||
_528 TILs and counting..._
|
_529 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -393,6 +393,7 @@ _528 TILs and counting..._
|
|||||||
- [Finding The Source of Ruby Methods](ruby/finding-the-source-of-ruby-methods.md)
|
- [Finding The Source of Ruby Methods](ruby/finding-the-source-of-ruby-methods.md)
|
||||||
- [Identify Outdated Gems](ruby/identify-outdated-gems.md)
|
- [Identify Outdated Gems](ruby/identify-outdated-gems.md)
|
||||||
- [If You Detect None](ruby/if-you-detect-none.md)
|
- [If You Detect None](ruby/if-you-detect-none.md)
|
||||||
|
- [Ins And Outs Of Pry](ruby/ins-and-outs-of-pry.md)
|
||||||
- [Invoking Rake Tasks Multiple Times](ruby/invoking-rake-tasks-multiple-times.md)
|
- [Invoking Rake Tasks Multiple Times](ruby/invoking-rake-tasks-multiple-times.md)
|
||||||
- [Last Raised Exception In The Call Stack](ruby/last-raised-exception-in-the-call-stack.md)
|
- [Last Raised Exception In The Call Stack](ruby/last-raised-exception-in-the-call-stack.md)
|
||||||
- [Limit Split](ruby/limit-split.md)
|
- [Limit Split](ruby/limit-split.md)
|
||||||
|
|||||||
26
ruby/ins-and-outs-of-pry.md
Normal file
26
ruby/ins-and-outs-of-pry.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Ins And Outs Of Pry
|
||||||
|
|
||||||
|
When executing commands during a [Pry](http://pryrepl.org/) session, you'll
|
||||||
|
see an incrementing number for each prompt as you enter each statement.
|
||||||
|
These numbers can be used to look up the inputs and outputs of each
|
||||||
|
statement executed during the session. The statements and their results are
|
||||||
|
made available in the array-like `_in_` and `_out_` objects.
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
[1] pry(main)> :one
|
||||||
|
=> :one
|
||||||
|
[2] pry(main)> 1 + 1
|
||||||
|
=> 2
|
||||||
|
[3] pry(main)> ["t", "h", "r", "e", "e"].join
|
||||||
|
=> "three"
|
||||||
|
[4] pry(main)> _in_.to_a
|
||||||
|
=> [nil, ":one\n", "1 + 1\n", "[\"t\", \"h\", \"r\", \"e\", \"e\"].join\n"]
|
||||||
|
[5] pry(main)> _out_.to_a
|
||||||
|
=> [nil, :one, 2, "three", [nil, ":one\n", "1 + 1\n", "[\"t\", \"h\", \"r\", \"e\", \"e\"].join\n"]]
|
||||||
|
[6] pry(main)> _out_[2]
|
||||||
|
=> 2
|
||||||
|
[7] pry(main)> _in_[2]
|
||||||
|
=> "1 + 1\n"
|
||||||
|
```
|
||||||
|
|
||||||
|
[source](https://github.com/pry/pry/wiki/Special-Locals#In_and_out)
|
||||||
Reference in New Issue
Block a user