Still have questions? Join our Discord server and get real time help.
0

# Is it possible to create table dictionaries with more then one response?

UPumpkin -34
8 months ago

For example

hi = {

["sup"] = "100","300"

}


Would it be possible to make it choose between the first and second of the ones listed, for example how would I make it so the 300 prints and how would I make it so the 100 prints. Assuming this is possible.

1
gullet 403
8 months ago

You simply put a table in a table. If you want to index at random you can use the Random type to generate random index.

local outer = {
["inner"] = {"100", "300"}
}

print(outer["inner"][1])
print(outer["inner"][2])

0
Answered by 8 months ago

This is what I usually do to solve this dilemma.

local Foo = {
Bar = {"100", "300"},
Baz = {math.sqrt(-1)^2}
}

print(Foo.Bar[1]) -- 100
print(Foo.Baz[1]) -- should be -1, but may be -nan(ind)