Re: question about 0 as exp in repeat-until
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: question about 0 as exp in repeat-until
- From: sagasw <sagasw@...>
- Date: 2010年1月21日 14:55:41 +0800
I get it, it is a very low-level mistake.
I think it as wrong way.
------------------------------------
C++, Lua, living in Dalian
http://sunxiunan.com/ http://twitter.com/sagasw
------------------------------------
On Thu, Jan 21, 2010 at 2:34 PM, Joseph Stewart
<joseph.stewart@gmail.com> wrote:
"while 0" is the same thing as saying "while true" (meaning loop forever or until "break"), by the same rule "until 0" is the same thing as saying "until true" which means only one pass through the loop.
-joe
On Thu, Jan 21, 2010 at 1:22 AM, sagasw
<sagasw@gmail.com> wrote:
I find an interesting issue in following code:
local i = 0;
while 0 do
i = i +1
if i > 10 then
break
end
print(i)
end
i = 0
repeat
i = i + 1
print(i)
if i > 10 then
break
end
until 0
I want to print 1 to 9 twice.
But in next repeat-until 0, it will only run once and print 1 only,
could somebody help me? Thanks
------------------------------------
C++, Lua, living in Dalian
http://sunxiunan.com/
http://twitter.com/sagasw
------------------------------------