The same concept works in Javascript which is described in more detail here.
This is a nice pattern in Lua to make it possible to add parameters to a function without needing to break backwards compatibility with older code.
Say we make a first version of a function and it takes two parameters one parameter like this:
Code Block | ||
---|---|---|
| ||
function FOO(T) local Data = T.data end |
...
Then we realize that we need a timeout, we can extend the function to support this a second parameter without needing to alter previous code calling this function. In fact we can code things in a way that adds a default.
...