Logical Operators

3.4.5 – Logical Operators The logical operators in Lua are and, or, and not. Like the control structures (see §3.3.4), all logical operators consider both false and nil as false and anything else as true. The negation operator not always returns false or true. The conjunction operator and returns its first argument if this value is false or nil; otherwise, and returns its second argument. The disjunction operator or returns its first argument if this value is different from nil and false; ot

Local Declarations

3.3.7 – 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 §3.3.3). Otherwise, all variables are initialized with nil. A chunk is also a block (see §3.3.2), and so local variables can be declared in a chunk outside any explicit block. The visibility rules for local variables are explained i

loadfile()

loadfile ([filename [, mode [, env]]]) Similar to load, but gets the chunk from file filename or from the standard input, if no file name is given.

load()

load (chunk [, chunkname [, mode [, env]]]) Loads a chunk. If chunk is a string, the chunk is this string. If chunk is a function, load calls it repeatedly to get the chunk pieces. Each call to chunk must return a string that concatenates with previous results. A return of an empty string, nil, or no value signals the end of the chunk. If there are no syntactic errors, returns the compiled chunk as a function; otherwise, returns nil plus the error message. If the resulting function has

ipairs()

ipairs (t) Returns three values (an iterator function, the table t, and 0) so that the construction for i,v in ipairs(t) do body end will iterate over the key–value pairs (1,t[1]), (2,t[2]), ..., up to the first nil value.

io.write()

io.write (···) Equivalent to io.output():write(···).

io.type()

io.type (obj) Checks whether obj is a valid file handle. Returns the string "file" if obj is an open file handle, "closed file" if obj is a closed file handle, or nil if obj is not a file handle.

io.tmpfile()

io.tmpfile () In case of success, returns a handle for a temporary file. This file is opened in update mode and it is automatically removed when the program ends.

io.read()

io.read (···) Equivalent to io.input():read(···).

io.popen()

io.popen (prog [, mode]) This function is system dependent and is not available on all platforms. Starts program prog in a separated process and returns a file handle that you can use to read data from this program (if mode is "r", the default) or to write data to this program (if mode is "w").