How to suppress the output of return value in IRB/Rails Console?
If you just want to suppress long output once in a while, use ;0
, like:
a = [*1..10000];0# => 0
If you want to suppress it generally, use the ~/.irbrc file. The IRB.conf[:INSPECT_MODE] and IRB.conf[:PROMPT][your_prompt][:RETURN] control what is returned. You can figure out what your_prompt is by checking IRB.conf[:PROMPT_MODE]
Example:
IRB.conf[:PROMPT][:DEFAULT][:RETURN] = "" # suppress return value completely
You'll need to restart irb after changing the value.
Hope that helps.
You can also supress the output with the following command as irb --simple-prompt --noecho
.
Find the below:
@ubuntu:~$ irb --simple-prompt>> puts "hi"hi=> nil>> p "hi""hi"=> "hi">> exit@ubuntu:~$ irb --simple-prompt --noecho>> puts "hi"hi>> p "hi""hi">>
Hope you will be fine with it.
I am using ruby version as below :
@ubuntu:~$ ruby -vruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
From @Tallboy dead link
To suppress the return value in Rails console, enterconf.return_format = ""
Default (Print the return value)conf.return_format = "=> %s\n"