Q:

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

belongs to collection: Ruby Strings Programs

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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 MyStr1MyStr2 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.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Ruby Strings Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Ruby program to create a String object... >>
<< Ruby program to illustrate the creation of strings...