lua循环

for
for i=1,5 do
  print(i)
end

1
2
3
4
5



local a = {"a", "b", "c", "d"}
for k, v in ipairs(a) do
  print("index:", k, " value:", v)
end

index:	1	 value:	a
index:	2	 value:	b
index:	3	 value:	c
index:	4	 value:	d


while
a=1
repeat
  print(a)
  a = a+1
until(a>=5)

1
2
3
4


a=1
while a<=5 do
  print(a)
  a = a+1
end

1
2
3
4
5

猜你喜欢

转载自xiangjie88.iteye.com/blog/2272688
LUA