Material Box

Material Box

WEB Design & Material Images

Godot - Make Array Immutable

Godot

GDScript code example to make an array read-only (immutable).


In GDScript, you can use make_read_only() to make an array immutable, preventing any modifications.
Attempting to modify the contents of an array that has been made read-only will result in an error.

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

array[0] = "pineapple"
# Invalid set index '0' (on base: 'Array') with value of type 'String'

Godot

TitleGodot - Make Array Immutable

CategoryGodot

Created

Update

AuthorYousuke.U