Ruby console [IRB] disable echo output

Ruby console [IRB] echoes the output of last line executed. Sometimes, when data to output is huge, it is quite troublesome. To disable echo in IRB, we need set a echo flag on conf to false.

By default, we have an access to IRB::Context instance variable conf.

$ conf.class
# IRB::Context < Object

Disable echo on IRB console

To disable to output of last executed line, we can set echo to false.

By default, it has true value as given below.

$ conf.echo
# true

Set echo to false as given below.

$ conf.echo
# false

Now, IRB console won’t output anything unless explicitly asked for with puts, print etc.

$ site_name = 'RUBY IN RAILS'

The above line doesn’t output anything. If we want to output something, we can use puts as given below.

$ site_name = 'RUBY IN RAILS'
$ puts site_name
# RUBY IN RAILS

IRB::Context provides echo? to check if conf is set to true

$ conf.echo?
# true

Note: This will only output result only if conf.echo? is set to true.

References