Ruby Hello World Program

In this tutorial you will learn about the Ruby Hello World Program and its application with practical example.

Creating Ruby Hello World Program

The “Hello world!” program is a simplest program that will display some text on the screen. The “Hello world!” program is a simple yet complete program for beginners that illustrates the basic syntax of any programming language. The “Hello world!” program gives you a way to test systems and programming environment.

This tutorial will guide you through writing a basic “Hello, World” program in Ruby.

Prerequisites

Before starting with this tutorial we assume that you already have Ruby installed (If you do not have Ruby installed then install it before you get started) as well as a local programming environment set up on your computer.

Step 1:- Create a file called “hello_world.rb” using a text editor program of your choice. The .rb file extension is used to specify Ruby language file.

Step 2:- Let’s open the “hello_world.rb” file that we created, and put the following line of code in it and save it.

The puts tells Ruby to display or output the content inside the parentheses.

Step 3:- Now, open terminal or command prompt and switch to the folder where our “hello_world.rb” file is saved. Run the program by typing the following command –

Once the program is executed it will print “Hello World!”.

Output:-

 

In this tutorial we have learn about the Ruby Hello World Program and its application with practical example. I hope you will like this tutorial.