Functions and Scope
Return Values
return sends a computed value back to the caller.
Return Values
return_values.lua
local width =
local function area(side)
return side * side
end
local result = area(width)
print("width=" .. width)
print("area=" .. result)
local width =
local function area(side)
return side * side
end
local result = area(width)
print("width=" .. width)
print("area=" .. result)
local width =
local function area(side)
return side * side
end
local result = area(width)
print("width=" .. width)
print("area=" .. result)
computed result
Store the returned value when later code needs to use or print it.