assignment |
---|
Assignment lets you "assign" (set) a variable to a value.
You can do multiple assignments, eg.
That does the same thing as the first example. Multiple assignments are not generally used on their own (they can be confusing to read), except in collecting the results from a function. Functions can return multiple results, so multiple assignment is a useful way of getting those results. eg.
In this example, a will get the start character position of the match, b will get the end position, and c will get the capture. With multiple assignment, if you (or the function) provides too few values, the extra ones are set to nil, eg.
This sets a to 0, b to 1, and c and d are both set to nil. If you provide too many values, the extra ones are silently discarded, eg.
The values 2, 3, 4, 5, 6 are just discarded. See Also ... Lua keywords/topics
Topics
(Help topic: lua=assignment) |
Enter a search string to find matching documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.