Improved Prompt Method
Welcome to little random thoughts of Ruby… My topic tonight is about the prompt snippet I gave yesterday. I didn’t realize it, as often happens, but it was so simple, I had to add the feature.
I realized while writing another wrapper for benchmark and profiler, that it is pretty common to add chomp() to our gets. But there may be times when we want what gets, um… well, gets. (Who am I to assume what you may want?) So I give an option. I default to a plain old string that is stripped. But you can easily get the true gets result by asking for true results. Can you guess that the flag to get it could be ‘true’?
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
In my irb, Here are a couple of examples…
1 2 3 4 5 6 |
|
Well, I thought it was pretty cool.