eval()loadstring()dofile()loadfile()loadstring() function in Lua?
loadstring() help create in Lua?
function keyword onlyloadstring() to define a functionlocal inside functionsetmetatable() do in Lua metaprogramming?
getmetatable() return?
function keywordloadstring()io.open()require()do blocksetmetatable()loadstring()?load()loadstring()dofile()loadfile()local f = loadstring("return function() return 42 end")()?+ operator for tables in Lua?__add metamethodsetmetatable()table.insert()loadstring()__index metamethod used for in Lua?table.concat()setmetatable()getmetatable()table.insert()__call metamethod in Lua tables?__default metamethod__index metamethod__newindex metamethodtable.insert()local t = {} setmetatable(t, {__index = function(t, key) return "default" end}) print(t.someKey)?nildefaultsomeKey__newindex metamethod in Lua?table.insert() do in Lua?__add metamethodtable.concat()table.merge()table.copy()| Qno | Answer (Option with the text) |
|---|---|
| 1 | B. Writing code that generates other code |
| 2 | B. loadstring() |
| 3 | B. Compiles a Lua code string into a function |
| 4 | B. A function at runtime |
| 5 | C. To generate repetitive code blocks dynamically |
| 6 | B. Using loadstring() to define a function |
| 7 | D. Changes the behavior of tables |
| 8 | D. The metatable of a table |
| 9 | B. It makes code more reusable |
| 10 | B. Creating a function during runtime |
| 11 | B. loadstring() |
| 12 | C. As a function reference |
| 13 | B. When the function needs to handle various behaviors at runtime |
| 14 | C. Allows for flexible function behaviors |
| 15 | C. The function is compiled and returned |
| 16 | B. loadstring() |
| 17 | B. A function returning 42 |
| 18 | B. By allowing for runtime function customization |
| 19 | B. To modify table behavior and operations |
| 20 | A. Using the __add metamethod |
| 21 | A. To set default values for undefined table keys |
| 22 | B. setmetatable() |
| 23 | B. A table where references to objects are weak |
| 24 | C. It allows automatic memory management |
| 25 | A. To enable tables to be invoked as functions |
| 26 | B. Use __index metamethod |
| 27 | B. Prints default |
| 28 | B. To define the behavior of adding new keys |
| 29 | C. Adds an element to the end of a table |
| 30 | A. __add metamethod |