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

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 > 

Stick a semi-colon behind the command and it doesn't print, works for both pry and irb

PRY

[1] pry(main)> a = true
=> true
[2] pry(main)> a = true;
[3] pry(main)>

IRB

2.0.0p247 :001 > a = true
 => true
2.0.0p247 :002 > a = true;
2.0.0p247 :003 >

Tags:

Ruby

Irb