Arrays to a single value?

Godot Version

Godot 4

Question

is there a way to turn arrays into single values?

like can i turn a single value string array into a string (this array)

var Single_array : Array = [‘string’] → var string : String = ‘string’ ?

and can i turn multiple valued arrays into single arrays with the first value?

[‘str1’, ‘str2’] → [‘str1’]?

This example will make a copy of the variables, I show using indecies and then using dedicated functions.

var array = ["str1", "str2"]

var value = array[0]
var value = array.front()
value == "str1"

var single_array = [array[0]]
var single_array = array.slice(0, 1)
single_array == ["str1"]
1 Like

damn thanks