summaryrefslogtreecommitdiff
path: root/tests/test.lua
blob: 32e18c79522fab2f9812530d08c7d8211ac6a520 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-- Standard function declaration
function hello(name)
    print("Hello, " .. name)
end

-- Local function declaration
local function secret_formula(x, y)
    return x * y + 42
end

-- Function assigned to a variable
myfunc = function(a, b)
    return a - b
end

-- Method-like function
local MyTable = {}
function MyTable:greet()
    print("Greetings!")
end

-- Nested function
function outer()
    local function inner()
        print("I am inside")
    end
    inner()
end

hello("User")
secret_formula(1, 2)
myfunc(10, 5)
MyTable:greet()
outer()