Doing Something

So far, after your program is done running, there’s really no evidence that it ever ran (aside from your memory of it). Nothing on your computer has been changed at all. The least I can do is show how to save the output of your program. For example, let’s say you wanted to save the output of your nifty new “99 Bottles of Beer on the Wall” program. All you have to do is add a little bit onto the command line when you run it:

ruby 99bottles.rb > lyrics.txt

That’s not even really programming; that’s just a command-line trick. And it’s not a terribly exciting one, since you can’t really use it for a program with any kind of interactivity or to save to more than one file or to save at a time other than the end of the program…. But, hey—it’s something. What’s happening is that all of the program’s output (from all of the putses) is being grabbed and funneled to the named file instead of being printed on your screen.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.249.220