Programming in Lua - 5
Programming in Lua - 5
Programming in Lua
Part I. The Language
Chapter 5. Functions
5 – Functions
Functions are the main mechanism for abstraction of statements
and
expressions in Lua.
Functions can both carry out a specific task
(what is
sometimes called procedure
or subroutine in other languages)
or compute and
return values.
In the first case, we use a function call as a statement;
in the
second case, we use it as an expression:
print(8*9, 9/8)
a = math.sin(3) + math.cos(10)
print(os.date())
message]] message]])
local sum = 0
sum = sum + v
end
return sum
end
CALL PARAMETERS
n = n or 1
count = count + n
end