Ruby program to convert an integer array into a string

Ruby Example: Write a program to convert an integer array into a string.
Submitted by Nidhi, on January 06, 2022

Problem Solution:

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

Program/Source Code:

The source code to covert an array of integers into the string is given below. The given program is compiled and executed successfully.

# Ruby program to covert an 
# integer array into string

arr = [1,2,3,4,5];

str = arr.join();

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

Output:

Str: 12345

Explanation:

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

Ruby Strings Programs »




Comments and Discussions!

Load comments ↻





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