setmetatable(table, metatable)table.metatable = metatabletable.set(metatable)metatable.table = tablegetmetatable()table.get()table.metatable()metatable.get()__index metamethodsetmetatable() function__newindex metamethodsetmetatable() function do in Lua?
__index__newindex__add__sub__add metamethod in Lua?
__index metamethod do?
__newindex metamethod differ from __index?
__index is used for getting values, __newindex is used for setting values__index is used for assigning values__newindex cannot be customized__add__sub__mul__div__call metamethod in Lua?
__sub__add__mul__div__tostring metamethod do?
+ on a table without defining the __add metamethod?
__index metamethod__metatable metamethod do?
== operator for a table in Lua?
__eq metamethod__compare metamethod__equal metamethod__ne metamethod* operator in Lua?
__mul__div__pow__mod.. operator in Lua using metamethods?
__concat metamethod.. operator cannot be overloaded__add metamethod__tostring metamethod>= operator in Lua?
__le__ge__gt__lt.. operator on a table without defining the __concat metamethod?
__lt (less than)__for__if__else<= operator for a table in Lua?
__le metamethod__eq metamethod__lt metamethod__compare metamethod__div metamethod define in Lua?
local keyword== and ~= using metamethods in Lua?
__eq and __neq__lt and __gt| Qno | Answer (Option with the text) |
|---|---|
| 1 | a) A special table that modifies the behavior of another table |
| 2 | a) setmetatable(table, metatable) |
| 3 | a) getmetatable() |
| 4 | a) It behaves normally without any modifications |
| 5 | a) To extend the capabilities of tables by modifying their behavior |
| 6 | b) They allow for modification of table behaviors for operations like indexing |
| 7 | a) Yes, multiple tables can reference the same metatable |
| 8 | a) By using the __index metamethod |
| 9 | a) Assigns a metatable to a table |
| 10 | a) Yes, metatables can be changed during runtime |
| 11 | a) __index |
| 12 | a) It defines how two tables are added together |
| 13 | a) It handles the default behavior when a non-existing index is accessed |
| 14 | a) __index is used for getting values, __newindex is used for setting values |
| 15 | a) __add |
| 16 | a) It allows a table to be called as a function |
| 17 | a) __sub |
| 18 | a) It defines how a table is converted to a string |
| 19 | a) Lua will throw an error |
| 20 | a) It prevents a table’s metatable from being modified |
| 21 | a) By defining the __eq metamethod |
| 22 | a) __mul |
| 23 | a) Yes, by defining the __concat metamethod |
| 24 | a) __le |
| 25 | a) Lua will throw an error |
| 26 | a) __lt (less than) |
| 27 | a) By defining the __le metamethod |
| 28 | a) The behavior of division on a table |
| 29 | a) By using metamethods |
| 30 | a) Yes, by defining __eq and __neq |