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
.
Disable 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.
Set echo
to false
as given below.
Now, IRB console won’t output anything unless explicitly asked for
with puts
, print
etc.
The above line doesn’t output anything.
If we want to output something,
we can use puts
as given below.
IRB::Context provides
echo?
to check if conf is set to true
Note: 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