Chapter 1 Numbers

Learn to Program, Third Edition — by Chris Pine (10 / 116)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 The Art of Programming | TOC | Printing to the Screen 👉

Are you ready to start programming? Is Ruby installed and do you have a text editor picked out? If not, check out the appropriate appendix to get things set up on your computer.

Open your text editor, and type the following:

​ puts 1+2

Save your program (yep, that’s a complete program) as calc.rb. Run it by typing ruby calc.rb into your command line. You’ll see that it puts a 3 on your screen.

What, you didn’t see it? Maybe you saw a window flash up and then disappear? Whatever the case may be, if you don’t see a 3 on your screen, the problem could be that you didn’t run the program from the command line.

Don’t just click your program’s icon.

Don’t just press F5 in your text editor.

You need to run your program by typing ruby calc.rb into your command line.

So, what’s going on here? How does your program work and what does it do? You’re about to find out.

👈 The Art of Programming | TOC | Printing to the Screen 👉

Learn to Program, Third Edition by Chris Pine can be purchased in other book formats directly from the Pragmatic Programmers. If you notice a code error or formatting mistake, please let us know here so that we can fix it.

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.