Skip to content

Commit d573ec4

Browse files
committed
Add Silence The Output Of A Ruby Statement In Pry as a ruby til
1 parent 3279cf3 commit d573ec4

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
1010
For a steady stream of TILs from a variety of rocketeers, checkout
1111
[til.hashrocket.com](https://til.hashrocket.com/).
1212

13-
_829 TILs and counting..._
13+
_830 TILs and counting..._
1414

1515
---
1616

@@ -677,6 +677,7 @@ _829 TILs and counting..._
677677
- [Scroll To Top Of Page With Capybara](ruby/scroll-to-top-of-page-with-capybara.md)
678678
- [Set RVM Default Ruby](ruby/set-rvm-default-ruby.md)
679679
- [Show Public Methods With Pry](ruby/show-public-methods-with-pry.md)
680+
- [Silence The Output Of A Ruby Statement In Pry](ruby/silence-the-output-of-a-ruby-statement-in-pry.md)
680681
- [Squeeze Out The Extra Space](ruby/squeeze-out-the-extra-space.md)
681682
- [String Interpolation With Instance Variables](ruby/string-interpolation-with-instance-variables.md)
682683
- [Summing Collections](ruby/summing-collections.md)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Silence The Output Of A Ruby Statement In Pry
2+
3+
Sometimes running a command in a [`pry`](https://github.com/pry/pry) session
4+
can produce a bunch of verbose output that you aren't interested in seeing.
5+
6+
Here is a contrived line of code whose output will take over the entire screen:
7+
8+
```ruby
9+
(1..200).map { |i| i*i }
10+
#=> [1,
11+
4,
12+
9,
13+
16,
14+
...
15+
```
16+
17+
You can silence all of this output by tacking on a single character -- `;`.
18+
19+
```ruby
20+
(1..200).map { |i| i*i };
21+
```
22+
23+
[source](https://gist.github.com/lfender6445/9919357)

0 commit comments

Comments
 (0)