×

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 illustrate the creation of strings

Last Updated : December 15, 2025

Problem Solution

In this program, we will illustrate the creation of string. Here, we will print strings enclosed with a single quote, double quotes, and also store string values inside the variables and print them.

Program/Source Code

The source code to illustrate the creation of strings is given below. The given program is compiled and executed successfully.

# Ruby program to illustrate the 
# creation of strings

# Create variables to store 
# string values
MyStr1 = "Hello World";
MyStr2 = 'Hello India';

puts MyStr1;
puts MyStr2;

# Print a string enclosed in 
# single quotes
puts 'Single quote string';

# Print a string enclosed in 
# double quotes
puts "Double quote string";

Output

Hello India
Single quote string
Double quote string

Explanation

In the above program, we created two variables MyStr1, MyStr2 to store string values and printed them. Here, we also printed the string enclosed within the single quote and double quote.

Ruby Strings Programs »


Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

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