Local Declarations

Lua Manual Version: 5.1
Local Declarations

Local variables can be declared anywhere inside a block. The declaration can include an initial assignment:

	stat ::= local namelist [`=´ explist]

If present, an initial assignment has the same semantics of a multiple assignment (see Assignment). Otherwise, all variables are initialized with nil.

A chunk is also a block (see Chunks), and so local variables can be declared in a chunk outside any explicit block. The scope of such local variables extends until the end of the chunk.

The visibility rules for local variables are explained in Visibility Rules.

These 1 functions may also be helpful

These 1 topics may also be helpful