Introduction Code Examples

How do I write Hello, World! program?

Let me introduce you to Ruby. Ruby is an object-oriented programming language that support dynamic programming styles. To start learning Ruby you'll need a Ruby interpreter installed in your computer. The small program below is the classic introductory program into programming language called Hello World.

Open your favorite text editor, type-in the following code and save it in a file called hello.rb. .rb is the extension name use for a file to store Ruby source code.

# Print Hello, World!
puts 'Hello, World!'

To run this program, execute the following command on the path where you store your hello.rb file.

$ ruby hello.rb

And the result will print the following text on the terminal.

Hello, World!

Example Categories