Let's write a simple program that displays Hello World!
on the screen.
puts "Hello World!"
Output
Hello World!
Note: A Hello World!
program is often the first step in learning a new programming language. It introduces you to the basic syntax and helps you understand how the language is structured.
Working of the Program
Now that you've written your first program, let's understand how it works.

In Ruby, puts
is a built-in method that prints the given text to the screen.
Key points about 'puts':
- The text you want to print is placed inside quotes, like
"Hello World!"
. - After printing, the cursor moves to a new line. So if you use another
puts
, its output appears on the next line.
You can also use single quotes to print text on the screen. For example,
puts 'Hello World!'
To be consistent, we'll use double quotes throughout these tutorials.
What's Next?
You've now written your first program and are ready to move to the next tutorial.
But if you've coded before, you can read our blog on Ruby Syntax to see how this programming language differs from others.