This article mainly introduces a concise example of function writing in Lua, this article is a personal learning note, a simple record of the LUA function, the need for friends can refer to the
function definition: Defines functions with keyword function, ending with keyword end
Local variables: Defined with the keyword locals. If the definition is not defined locally, even the variable defined within the function is a global variable!
function can have multiple return values: A,b,c ...
Parallel Assignment: A,b=c,d
Global variables: The preceding code defines three global variables: FOO,R1,R2
This is the first LUA function I wrote:
Copy code code as follows:
function foo (a,b,c)
Return sum,c--a function can have multiple returned values
R1,r2=foo (1, ' 123 ', "Hello")--parallel assignment