1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-07 00:58:02 +00:00

Add Ins And Outs Of Pry as a ruby til

This commit is contained in:
jbranchaud
2017-04-28 14:21:06 -05:00
parent 5d5442723d
commit 61cbb0f021
2 changed files with 28 additions and 1 deletions

View 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)