ADVERTISEMENT
ADVERTISEMENT

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 »


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.