[]{}()||table = {}table = []table = ()table = ||table[key] = valuetable.key = valueadd(table, key, value)table.add(key, value)table = {1, 2, 3}table = [1, 2, 3]table = (1, 2, 3)table = {1; 2; 3}nilfalsetable[key]table.get(key)table:keytable.getValue(key)for loop with pairs()for loop with next()while loop with pairs()repeat...until loop with pairs()for i, v in ipairs(table)for i, v in pairs(table)for i = 1, tablefor i in tablenext()pairs()get()nextkey()ipairs() function iterate through?
pairs() function return when iterating over a table?
for loop?
for i, v in pairs(table)for i, v in ipairs(table)next() function return?
for k, v in pairs(table)?
array keywordtable.remove()table.delete()table.clear()table.pop()#tabletable.length()table.size()table.count()nilfalsefor i = 1, #table dofor i, v in ipairs(table)for i, v in pairs(table)table = {}array = []array = ()array = ||niltable.insert(table, 1, value)table.add(1, value)table.unshift(value)table.push(1, value)array typetable.indexOf(value)table.find(value)table.index(value)| Qno | Answer |
|---|---|
| 1 | a) A data structure used to store data |
| 2 | b) {} |
| 3 | a) table = {} |
| 4 | a) Integer |
| 5 | a) table[key] = value |
| 6 | a) Yes, tables can store mixed data types |
| 7 | a) table = {1, 2, 3} |
| 8 | b) Lua returns nil |
| 9 | a) Yes, tables are used as objects |
| 10 | a) table[key] |
| 11 | a) for loop with pairs() |
| 12 | a) for i, v in ipairs(table) |
| 13 | a) next() |
| 14 | a) Only the numerical indices of a table |
| 15 | a) Key-value pairs |
| 16 | c) Both of the above |
| 17 | a) The next key-value pair in a table |
| 18 | a) Yes, tables can have both |
| 19 | a) Key-value pairs |
| 20 | a) By using consecutive integer indices |
| 21 | a) It creates a new key-value pair |
| 22 | a) table.remove() |
| 23 | a) #table |
| 24 | a) Lua returns nil |
| 25 | d) Both a and b |
| 26 | a) table = {} |
| 27 | b) 1 |
| 28 | a) table.insert(table, 1, value) |
| 29 | a) Yes, tables are dynamic |
| 30 | d) Lua does not provide a built-in function for this |