Skip to content

Instantly share code, notes, and snippets.

@rozer007
Last active December 4, 2021 11:51
Show Gist options
  • Save rozer007/d15cdd71178116d9003b039d2a2d398d to your computer and use it in GitHub Desktop.
Save rozer007/d15cdd71178116d9003b039d2a2d398d to your computer and use it in GitHub Desktop.
Modules in lua
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.
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