Q:

Ruby program to concatenate the strings using the << operator

belongs to collection: Ruby Strings Programs

0

In this program, we will create three strings. Then we will concatenate the strings using the "<<" operator and print the result.

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 concatenate the strings using the "<<" operator is given below. The given program is compiled and executed successfully.

# Ruby program to concatenate the 
# strings using "<<" operator

str1 = "Hello ";
str2 = "how ";
str3 = "are you. ";

str1 << str2 << str3;

print str1;

Output:

Hello how are you.

Explanation:

In the above program, we created three strings str1str2str3, that are initialized with "Hello ", "how ", "are you ". Then we concatenated the strings using the "<<" operator and printed the result.

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 iterate characters using the each_... >>
<< Ruby program to check a string is a numeric string...