This is my first time learn about recursive function, and I wrote a test code:
local function func(a)
a = a + 1
if a == 100 then
return a
elseif a > 100 then
return 100
else
func(a)
end
end
print(func(0)) --return nothing
The weird thing is it return nothing. Nothing in the output, not nil or anything, just nothing.
Here is another script that do the same thing, but it work:
local function func(a)
for i = 1, 100 do
a = a + 1
if a == 100 and not a > 100 then
return a
else
return 100
end
end
end
print(func(0)) --return 100
Did I do anything wrong or I'm just retarded.
Thank for reading :D

4 comments
Can you explain more please.
If you put a return there, calling func(0) will return func(1). But func(1) returns func(2), and func(2) returns func(3) and so on until it gets to func(100) which just returns 100. So the whole thing returns 100.
So what happen if I'm not put a return there?
I mean yeah it won't print anything, but what actually happen if there is no return?