content

Read-only Dictionarys are not read-only

You can make a Dictionary in Godot read-only by calling the function make_read_only(). This guarantees that inserts and deletions cannot be carried out on this instance of the dictionary in the future, but the keys and values in the dictionary can still be changed if they are reference types. 1

It would be slightly better if make_read_only returned a new type ReadOnlyDictionary, so that you couldn't even compile code that tries to modify a read-only dictionary, though I find the utility of this is questionable when value types and reference types are not evidently distinct from each other in the source code. 1

meta

tags: godot

created:

backlinks: Godot crimes

commit: 1968a19b