您的位置:首页 > 移动开发 > Objective-C

Silence output of return object in IRB console on windows

2017-03-04 03:17 423 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  windows IRB console ruby return
相关文章推荐