Exercise 1. A Good First Program

You should have spent a good amount of time in Exercise 0 learning how to install a text editor, run the text editor, run 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 text into a single file named ex1.rb. Ruby works best with files ending in .rb.

ex1.rb

 1    puts "Hello World!"  2    puts "Hello Again"  3    puts "I like typing this."  4    puts "This is fun."  5    puts "Yay! Printing."  6    puts "I'd much rather you 'not'."  7    puts 'I "said" do not touch this.'

If you are on Mac ...

Get Learn Ruby the Hard Way: A Simple and Idiomatic Introduction to the Imaginative World of Computational Thinking with Code, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.