Jan
23
Suppressing IRB Output
When in IRB or Console, you can often get back large blocks of output even when you didn’t want it. This happens often when inspecting your database through Console, working with SOAP responses, XML parsing, etc. You could always scroll up in your terminals buffer to find the results you were looking for, or, you can forcefully “suppress” the IRB output.
# using map # suppressing
# using each
>> User.all.each { |u| u.save }
=> [#
>> User.all.map { |u| u.save }
=> [true, true, true .... etc, etc, etc]
>> User.all.map { |u| u.save }; 0
=> 0
Just add a semi-colon followed by an object.
Finding this out after years of scrolling resulted in a large ‘facepalm’ on my part
3 Comments
Seriously, thanks for this post. It seems like I’ve been looking forever to find a way to get rid of this kind of data dump.
Ahh I remember the day I figured this one out. Changed my world. I do ‘and nil’.
Oh wow. So intuitive :-/
Been looking for a solution for months. Surely this must be a FAQ when using the console. My .find(:all)’s are suddenly much more pleasant!
Cheers.