Quieting irb's Return Value

It's easy to be overwhelmed by irb's automatic printing of return values, especially when dealing with collections of ActiveRecords in Rails' script/console.

This simple nugget will save you from an ocean of return values.

At the irb [or script/console] prompt, type:

conf.return_format = ""

The default (to print the return value) is:

conf.return_format = "=> %s\n"

To answer Jim's question (in the comments): you can easily limit the number of characters put into the result string by sprintf:

conf.return_format = "=> %.512s\n"

Replace 512 with your preferred return value character length limit.

About this Post

Author:
Mars
Published:
2006-10-06 11:38
Updated:
2006-10-07 19:12
Sections:
Ruby