Last active
December 4, 2021 11:51
-
-
Save rozer007/d15cdd71178116d9003b039d2a2d398d to your computer and use it in GitHub Desktop.
Modules in lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1.What is a module in lua | |
ans: A module is like a library full of functions and variables. | |
Q2.How do we create a modules ? | |
ans: It can be created as the same way as we create a tables, but the filename should be same as the module name. | |
Q3.How can we load a module in our lua file? | |
ans: We will require keyword which is used to gain access to the function of the modules. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1.What is correct way to define a function of module? | |
a) function fun_name() | |
b) function module_name.function_name() | |
c) function module_name:function_name() | |
d) none of the above | |
ans:c) | |
Q2.What is the module here : | |
convert={} | |
cn={} | |
nn={} | |
function convert.fttocm(feet) | |
return feet*30.48 | |
end | |
a) cn | |
b) nn | |
c) convert | |
d) no module | |
ans: c) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment