Dictionary

0

Dictionaries are an extension of arrays. While an array stores an ordered list of items, a dictionary stores a set of key-value pairs. To create a dictionary table, define each key followed by = and then the value

local testDictionary = {
    FruitName = "Lemon",
    Sour = true,
    SubD = {
        Boo = "Yeah"
    }   
}

testDictionary.FruitColor = "Yellow" -- insert a new key, value

print(testDictionary["FruitName"])
print(testDictionary.Sour) -- this format also works
print(testDictionary.FruitColor)
print(testDictionary.SubD.Boo)

  • 0 posts
  • 0 subtopics
  • 2 months ago by vince