Here's an example
local query = {}
query['count'] = 1
query['query'] = 2
for k,v in pairs(query) do
print(k)
end
The above will print first query
then count
.
How can I make sure without adding an int index key that the key strings keep their order when I loop through the table?
I answered in comment, but I'm moving it here to give a better idea of what I'm talking about.
local queryindex = {"count", "query"}
local query = {}
query['count'] = 1
query['query'] = 2
for _,v in ipairs(queryindex) do
print(query[v])
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With