The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Lets say you have a dictionary

var dict : Dictionary = {}

Lets say you wanted to set_defer a value.

The way I am aware of how to do this is like such...

func _ready():
var key = "Key"
var value = "Value"

func set_deferred_dict(key,value):
  dictionary[key] = value

However, I would like to know if it is possible to do this via the set_deferred

Is it possible to do something like

Godot version Godot Alpha 9
in Engine by (18 points)

1 Answer

0 votes

Dictionary isn't an Object and has no properties, so cannot be used with set_deffered by itself.

Although because you're using Godot 4, you can achieve more or less the same one liner by using a lambda:

var dict := {}
var key = "Key"
var value = "Value"

func _ready():
    (func(): dict[key] = value).call_deferred()
by (132 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.