Is typed dictionary able to take value as null?

Godot Version

4.4.1

Question

I just found that godot supports typed dictionary, but I seem to have problem to assign null as value in it:
I want to use a dictionary as a set, that I don’t care about the dictionary values, I just want the keys and use dictionary to prevent repeated element from presenting. So the value for every key can be anything, in order to take least memory and a little performence, it’s best to leave those useless values as null.
In normal dictionary that is not typed, it’s easy to do this. But if I want to do it with typed dictionary, I can’t figure out how to make it work, because null does not have a type. How can I achieve it or is it impossible?

You can use a Variant or Object type to give null values.

3 Likes

Thanks for the answer, that works.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.