ADVERTISEMENT
ADVERTISEMENT

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

Ruby Example: Write a program to illustrate the difference between single quote string and double-quote string.
Submitted by Nidhi, on December 30, 2021

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!



ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.