The return value of Enumerable::each is the object that called each.
When I am inside irb this is really annoying since I get huge outputs.
Is it possible to suppress the return value of Enumerable::each in irb?
For example this
[1,2].each {|u| puts "hey"}
output this
>> [1,2].each {|u| puts "hey"}
hey
hey
=> [1, 2]
I want to get rid of the last line
That is simple.
Just add a semicolon(;) at end of the statement/expression in Ruby whose return value you don't want to see and also add nil.
Make it:
[1,2].each {|u| puts "hey"}; nil
But please note that there is no reason to suppress the irb output(except when the return value is too large/lot of text); it helps a lot in debugging and to know what exactly is going on in the function.
Add the --noecho flag.
How it works:
$ irb --noecho
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With