diff --git a/README.md b/README.md index 65fa6f2..b7e3ef6 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_829 TILs and counting..._ +_830 TILs and counting..._ --- @@ -677,6 +677,7 @@ _829 TILs and counting..._ - [Scroll To Top Of Page With Capybara](ruby/scroll-to-top-of-page-with-capybara.md) - [Set RVM Default Ruby](ruby/set-rvm-default-ruby.md) - [Show Public Methods With Pry](ruby/show-public-methods-with-pry.md) +- [Silence The Output Of A Ruby Statement In Pry](ruby/silence-the-output-of-a-ruby-statement-in-pry.md) - [Squeeze Out The Extra Space](ruby/squeeze-out-the-extra-space.md) - [String Interpolation With Instance Variables](ruby/string-interpolation-with-instance-variables.md) - [Summing Collections](ruby/summing-collections.md) diff --git a/ruby/silence-the-output-of-a-ruby-statement-in-pry.md b/ruby/silence-the-output-of-a-ruby-statement-in-pry.md new file mode 100644 index 0000000..979da82 --- /dev/null +++ b/ruby/silence-the-output-of-a-ruby-statement-in-pry.md @@ -0,0 +1,23 @@ +# Silence The Output Of A Ruby Statement In Pry + +Sometimes running a command in a [`pry`](https://github.com/pry/pry) session +can produce a bunch of verbose output that you aren't interested in seeing. + +Here is a contrived line of code whose output will take over the entire screen: + +```ruby +(1..200).map { |i| i*i } +#=> [1, +4, +9, +16, +... +``` + +You can silence all of this output by tacking on a single character -- `;`. + +```ruby +(1..200).map { |i| i*i }; +``` + +[source](https://gist.github.com/lfender6445/9919357)