Change the value of a constant!! Is this a bug?

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

Is this a bug?

const thing = ["a","b"]
func _ready():
	thing[0] = "c"
	thing[1] = "d"
	print(thing)

No error on output window, and the result is (c,d) !!!

:bust_in_silhouette: Reply From: Rhelmar

From the GDScript Documentation:

Since arrays and dictionaries are passed by reference, constants are
“flat”. This means that if you declare a constant array or dictionary,
it can still be modified afterwards. They can’t be reassigned with
another value though.

:bust_in_silhouette: Reply From: jgodfrey

It seems that’s as designed though potentially unexpected. See:

https://www.godotforums.org/discussion/23252/array-typed-as-const-is-not-constant

… and …