Remember, you should have spent a good amount of time in Exercise 0 learning how to install a text editor, run the text editor, run the Terminal, and work with both of them. If you haven't done that then do not go on. You will not have a good time. This is the only time I'll start an exercise with a warning that you should not skip or get ahead of yourself.
Type the following into a single file named ex1.rb. This is important as Ruby works best with files ending in .rb.
1 2 3 4 5 6 7 | puts "Hello World!"
puts "Hello Again"
puts "I like typing this."
puts "This is fun."
puts 'Yay! Printing.'
puts "I'd much rather you 'not'."
puts 'I "said" do not touch this.'
|
Then in Terminal run the file by typing:
ruby ex1.rb
If you did it right then you should see the same output I have below. If not, you have done something wrong. No, the computer is not wrong.
$ ruby ex1.rb
Hello World!
Hello Again
I like typing this.
This is fun.
Yay! Printing.
I'd much rather you 'not'.
I "said" do not touch this.
$
You may see the name of your directory before the $ which is fine, but if your output is not exactly the same, find out why and fix it.
If you have an error it will look like this:
ruby ex1.rb
ex1.rb:4: syntax error, unexpected tCONSTANT, expecting $end
puts "This is fun."
^
It's important that you can read these since you will be making many of these mistakes. Even I make many of these mistakes. Let's look at this line-by-line.
You will also have Extra Credit. The Extra Credit contains things you should try to do. If you can't, skip it and come back later.
For this exercise, try these things:
Note
An 'octothorpe' is also called a 'pound', 'hash', 'mesh', or any number of names. Pick the one that makes you chill out.