×

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 difference between single quote string and double-quote string

Last Updated : December 15, 2025

Problem Solution

In this program, we will illustrate the difference between a single quote string and a double-quoted string. The single quote string cannot interpolate the variables.

Program/Source Code

The source code to illustrate the difference between single quote string and double-quote string is given below. The given program is compiled and executed successfully.

# Ruby program to illustrate the difference between 
# single quote string and double-quote string.

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

puts 'Single quote string: #{Mystr1}';
puts "Double quote string: #{MyStr2}";

Output

Single quote string: #{Mystr1}
Double quote string: Hello India

Explanation

In the above program, we created two variables MyStr1, MyStr2 to store string values. Then we used single quote and double quote strings to interpolate string variables and found that we cannot interpolate string variables inside the single quote string.

Ruby Strings Programs »


Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

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