Setter for Dictionary type variable

Godot Version

4.3.stable

Question

How to set a setter for Dictionary type variable?
For example: when target key already in use, then run push_warming() and replace the original value.

Here’s syntax for setters and getters explained.

Let me know in case you have troubles with your implementation.

You won’t be able to use getters/setters directly with dictionary content.
You will have to use functions.
(Some code from you would have helped here however…)

var my_dictionary:Dictionary = { "A":12,  "B":28,  "C":65 }  
func set_dict_values(k:String, v:int)->void: 
   if my_dictionary.has(k): 
      push_warming()
   my_dictionary[k] = v
1 Like