Printing to the Screen
Learn to Program, Third Edition — by Chris Pine (11 / 116)
👈 Chapter 1 Numbers | TOC | Integers and Floats 👉
Looking at the program, you can guess that the 1+2 handles the math part. In fact, you can simply write this:
puts 3
And you’ll end up with the same result: a 3 on your screen.
You may have guessed by now that the puts method writes onto the screen whatever comes after it; for example, the result of 1+2.
Now let’s talk about the two different kinds of numbers that we can use in our programs.
👈 Chapter 1 Numbers | TOC | Integers and Floats 👉
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.