Re: Why does this exit the function early?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Why does this exit the function early?
- From: Mike Crowe <drmikecrowe@...>
- Date: 2009年6月18日 13:10:09 -0400
You were using "break" as if it were "continue", which lua doesn't have.
break terminates the while loop.
Paul Butler wrote:
Newbie question.....
Why does the "break" end the function?
I was expecting it to count to 10 and just skip over 5.
function doThis()
local count = 0
while true do
count = count + 1
if count == 5 then break end
print(count)
if count == 10 then return end
end
print("why are we here?")
end
doThis()