I'm working in C#. I'm used to being able to use tuples as keys in a Dictionary, and so I was surprised when I tried doing so and encountered this error:
ERROR: Attempted to convert an unmarshallable managed type to Variant. Name: "ValueTuple"2' Encoding: 21.
I realized after some googling that I can and should just use the Dictionary in System.Collections.Generic
, so that solved my current problem. It made me wonder though: what can or cannot be used as an element (or key) in an Array or Dictionary? I'm having trouble finding a good resource to answer that clearly.
Looking at the page on Variants, it would appear that I can use anything which inherits from System.Object
. Is that true? Also, it seems that there are special cases for primitives and strings. Structs appear to not be allowed. Are enums allowed? Are there other value types which aren't allowed?
Furthermore, if I'm using an object as a key, does Godot's Dictionary utilize Equals and GetHashCode the same as System.Collections.Generic.Dictionary
does?
Thanks for answering any of these questions! And if there is a resource which explains some or all of this, please point me at it!