Dictionaries vs Mutable structs

Hello,

Are there any rules of thumb that one can use to choose between Dictionaries and Mutable structs? I am trying to understand when is it better to choose one over other, since I think both can be used in some cases.

Thank you.

Do you have a small fixed amount of data with known names and types? Then you may want a mutable struct. Do you have a large amount of data with variable names and either unknown type or all the same type? Then you may want a dictionary. Mutable structs are also much smaller and more efficient than dictionaries. There are certainly cases where you could use either one.

3 Likes

Thanks very much for these pointers. That makes it easy to decide in my case.