lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Lack of switch is not so bad since you can replace that with 'elseif's or even a lookup table, for that matter (which is a very lua-like way of doing it..)

As to 'continue', i've found no such adequate bypass, yet.

Well, perhaps this is just a hole, and moons have holes.. :)


ps. Apart from being "orthogonal" with 'break', adding 'continue' would also make it easier for newcomers to embrace Lua. One less faq..

Nick Trout kirjoittaa tiistaina, 17. kesäkuuta 2003, kello 22:48:

Every time I write a little program I end up wanting a continue
statement for loops. Does this exist already or is there an
that I've missed? If not then how to people not write ugly
"if this then ... if that then ... if other then ... end end
end" code to serve the same purpose of just jumping back to
the top of the loop?

There's no switch statement either. You might emulate continue using

	done = false
	while not done do
		local i = 1
		while true do
			if ... then
				break -- continue
			...some processing...
			if ..some test... then
				done = true
		i = i+1 -- next iteration