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:
![](https://oscdn.geek-share.com/Uploads/Images/Content/201703/30ba4c438cc624df7ba7f798fca13e6f)
When it doesn't output return object:
![](https://oscdn.geek-share.com/Uploads/Images/Content/201703/63a7b851d169dc7d2c4b79c21b727c99)
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.
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.
相关文章推荐
- VB6:关于“Only public user defined types defined in public object modules can be used as parameters or return types for public procedures of class modules or as fields of public user defined types.”的编译错误
- xcode4.2:warning: Semantic Issue: Conflicting distributed object modifiers on return type in impleme
- GIT BASH IN INTELLIJ IDEA 13 ON WINDOWS One of the top features of the recent release of IntelliJ ID
- How to put an object on the request in a servlet
- Fatal error: Maximum execution time of 60 seconds exceeded in *.php on line...
- Notice to users of DB Query Analyzer in Windows 7, Windows 8 and Windows 10
- The return value of "mktime" in different time zone
- UISplitViewController in portrait on iPhone shows detail VC instead of master
- Run Nutch In Eclipse on Linux and Windows nutch version 0.9
- Reducing the Delay and Power Consumption of Web Browsing on Smartphones in 3G networks阅读笔记
- unexpected end of file in HotNewspro\includes\directory.php on line 22
- How to: Change color of rows in GridView on mouseover
- On The Value Of Fundamentals In Software Development (基础知识在软件开发中的价值)
- Advanced Threads(Chapter 4 of Concurrent Programming on Windows)
- one trick---Add console output in WinForm
- The Best Choice of Registry Cleaner on Windows XP
- Run Nutch In Eclipse on Linux and Windows nutch version 1.0
- “/dev/kvm not found ”error on windows in android studio
- What 's the meaning of "Windows-on-Windows" layer?
- Epic公司 面试题(找钱问题)题目:Write algorithm to return change in denominations of 10$, 5$, 1$, 25 cents, 10 ce