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 < ObjectDisable echo on IRB console
To disable the output of the last executed line,
we can set
echo
to false.
By default, it has true value as given below.
$ conf.echo
# trueSet echo to false as given below.
$ conf.echo
# falseNow, 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 RAILSIRB::Context provides
echo?
to check if conf is set to true
$ conf.echo?
# trueNote: This will only output result only if conf.echo? is set to true.
References
Subscribe to Ruby in Rails
Get the latest posts delivered right to your inbox
