Ruby program to concatenate the strings using the << operator

Ruby Example: Write a program to concatenate the strings using the << operator.
Submitted by Nidhi, on January 06, 2022

Problem Solution:

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

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 str1, str2, str3, that are initialized with "Hello ", "how ", "are you ". Then we concatenated the strings using the "<<" operator and printed the result.

Ruby Strings Programs »




Comments and Discussions!

Load comments ↻





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