Material Box

Material Box

WEB Design & Material Images

Godot - Get first or last value in array

Godot

GDScript code example to get first or last value in array.


Can get first value in array using front() in GDScript.
Returns "null" if array is empty.

var array = ["apple", "lemon" , "banana"]
var first_value = array.front()

print(first_value)
# apple

Can get last value in array using back().
Returns "null" if array is empty.

var array = ["apple", "lemon" , "banana"]
var last_value = array.back()

print(last_value)
# banana

Godot

TitleGodot - Get first or last value in array

CategoryGodot

Created

Update

AuthorYousuke.U