Godot Version
4.3
Question
So I have been messing around with using Dictionaries a bit more often in my Godot projects, mainly for reading/loading JSON files, and in using them I’ve happened upon two ways to get info from them
Say I have a Dictionary called “colors”, which lists the colors of different fruits
var colors: Dictionary = {
"apple":"red",
"tangerine":"orange"
"lemon":"yellow"
"lime":"green"
}
Now, say I want to get the color of a lemon in code. My question is, what is the difference between the two methods of getting that info, and which would be the best to use, or when should I use one over the other?
# Using Dictionary.get()
colors.get("lemon")
# Using Dictionary[key]
colors["lemon"]