Material Box

Material Box

WEB Design & Material Images

Godot - Replace All Values in an Array with a Specified Value

Godot

GDScript code example to replace all values in an array with a specified value.


In GDScript, you can use fill() to replace all values in an array with a specified value.
This method replaces existing values or null with the specified value.

var array = ["apple", "lemon", "banana"]
array.fill("x")

print(array)
# ["x", "x", "x"]

When specifying a new array size, all values default to null, but using fill() allows you to replace them with a specific value.

var array = []
array.resize(3)
array.fill("x")

print(array)
# ["x", "x", "x"]

Godot

TitleGodot - Replace All Values in an Array with a Specified Value

CategoryGodot

Created

Update

AuthorYousuke.U