Search code examples
rubyirb

How can I avoid the console output when assigning a value to a variable in Ruby


Is it possible to escape that effect when assigning to a value:

irb(main):584:0>a = true
=>true
irb(main):584:0>

I have a code that has lots of assignings and when I am trying to test it I can not see the result because of all these returned values:

true
false
true
false
true
true
..

Solution

  • You can start the irb or console attaching the --noecho option.

    $ irb --noecho
    2.0.0p353 :001 > true
    2.0.0p353 :002 > 
    

    Otherwise, if the console was started by another process, simply set conf.echo = false

    $ irb 
    2.0.0p353 :001 > true
     => true 
    2.0.0p353 :002 > conf.echo = false
    2.0.0p353 :004 > true
    2.0.0p353 :005 >