How to convert array in to a string?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Radhe

for example:

this array:

var array = [1, 4, ‘.’, 0, 0, 0]

into

14.000

1 Like
:bust_in_silhouette: Reply From: jgodfrey

You’ll probably just need to iterate through the array, convert each element to a string, and concatenate the results. Here’s a function that does basically that:

func array_to_string(arr: Array) -> String:
	var s = ""
	for i in arr:
		s += String(i)
	return s

Call it like this:

var array = [1, 4, '.', 0, 0, 0]
var s = array_to_string(array)
print(s)
1 Like