</>
Tutorials

Lua Tutorial

  • Lua - Making Table Callable
    Some time we need to create function like objects. Lua provides a special metamethod __call. If __call is present in the associated metatable of the main table, then we can treat the table as argument. This is a useful in following cases ?
  • Lua - Proxy Table with metatables
    A proxy table can be defined as a table which is not storing actual data as it is representing to store. A proxy table is an intermediary which delegates operations to another table or another object. We can even choose to do some logic instead of storing data.
  • Lua - Module Caching
    Module caching refers to keeping a copy of module loaded and checking if it is already loaded before reloading the module. Lua keeps track of each module loaded using require statement. Lua maintains a global table package.loaded and caches the loaded module in this table.
  • Lua - Submodule
    When a module becomes very large, it is better to organize it into either small modules or we can create submodules. Lua supports submodule with an advantage that variable of main module is accessible in a submodule.
  • Lua - Concatenate List Elements
    Cancatenating lists means merging elements of two or more lists. We can achieve the same easily using below pseudo code. First we can create an empty list, iterate elements of each list and push them to the empty list. Now the empty list is the merged list.
  • Lua - Uses of Closures
    A closure function is an inner function which closes over local variable of the enclosing function. A closure is a powerful mechanism in Lua. In this chapter, we're discussing various scenarios and usage of closures.
Page 1 / 34Next