×

Ruby Tutorial

Ruby Basics

Ruby Control Statements

Ruby Methods

Ruby Classes and Methods

Ruby Arrays

Ruby Sets

Ruby Strings

Ruby Classes & Objects

Ruby Hash

Ruby Tools

Ruby Functions

Ruby Built-in Functions

Misc.

Ruby Programs

Ruby program to print Hello World!

Last Updated : December 14, 2025

Printing Hello World! In Ruby

To print text (Hello World! Or anything else), we use following two methods,

  1. puts : The word "puts" stands for put string. It adds a newline after the string.
  2. print : The functionality of this method is same as of puts but it does not adds newlines implicitly like puts.

Variables used: No variables are required as we only have to print the statements. We don't have to store anything.

Ruby code to print "Hello World!"

=begin 
Ruby program to print Hello World.
=end

puts "Hello World!"
print "Hello World!"
puts "Hello World!"

Output

Hello World!
Hello World!Hello World!

Code explanation:

The code illustrates an example to print a string "Hello World!" in Ruby programming language. This uses the puts and print methods to print the string and output "Hello world" using these methods.

You can observe in the output that the print method is not providing a newline and two statements are printing together. Though, both the methods have the same functionality but still use them wisely.

Ruby Basic Programs »


Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.