Notice: This is supposed to work for Rails console too. But somehow it only works for IRB console.
Let's see some examples first:
When it output return object:
When it doesn't output return object:
Why sometimes we may want to disable outputting return object?
Take my case as an example, I have a huge array, I want to loop through this array and print out some elements that accords with a certain criteria. With output return object enabled, it will print the elements, then output the whole array. Since the array is huge, even though I increase my console buffer to maximum, scroll to top, I still couldn't see the beginning of the array, not even mention the element output.
How to disable?
Create .irbrc file in %HOME% directory(For ex, mine is "C:\Users\yatwang". And add these lines in the file:
IRB.conf[:PROMPT][:NO_RETURN] = {
PROMPT_I: "%N(%m):%03n:%i> ",
PROMPT_S: "%N(%m):%03n:%i%l ",
PROMPT_C: "%N(%m):%03n:%i* ",
RETURN: "" # used to printf
}
IRB.conf[:PROMPT_MODE] = :NO_RETURN
An alternative: you can create a file with the same content. You can name it whatever you want, or put it anywhere you want. Just need to add a system environment variable "IRBRC", whose value points to the location of the file.