ADVERTISEMENT
ADVERTISEMENT

Ruby program to convert the array of characters into the string

Ruby Example: Write a program to convert the array of characters into the string.
Submitted by Nidhi, on January 05, 2022

Problem Solution:

In this program, we will create an array of characters. Then we will convert an array into the string using the join() function and return the result.

Program/Source Code:

The source code to convert the array of characters into the string is given below. The given program is compiled and executed successfully.

# Ruby program to covert the array 
# of characters into string

arr = ['H', 'E', 'L', 'L', 'O'];
str = arr.join();

print "Str: ",str,"\n";

Output:

Str: HELLO

Explanation:

In the above program, we created an array arr. Then we used the join() function to convert an array of characters into the string and assign the result to the str variable. After that, we printed the string str.

Ruby Strings Programs »


ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!



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.