Lua Functions Calling a function.

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Functions are only useful if we can call them. To call a function the following syntax is used:

print("Hello, World!")

We're calling the print function. Using the argument "Hello, World". As is obvious, this will print Hello, World to the output stream. The returned value is accessible, just like any other variable would be.

local added = add(10, 50) -- 60

Variables are also accepted in a function's parameters.

local a = 10
local b = 60

local c = add(a, b)

print(c)

Functions expecting a table or a string can be called with a neat syntactic sugar: parentheses surrounding the call can be omitted.

print"Hello, world!"
for k, v in pairs{"Hello, world!"} do print(k, v) end


Got any Lua Question?