[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Feature request: enhanced break
- From: Josh Simmons <simmons.44@...>
- Date: Mon, 24 Nov 2014 17:42:47 +1100
On Mon, Nov 24, 2014 at 5:39 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> Optional integer constant after "break" specifies number of enclosing
> loops to break. `break 1` means the same as `break` without a number.
>
> Example: find an item in a table of lists, with shortcut exit from a list.
>
> for k,a in pairs(t) do
> for n,b in ipairs(a) do
> if futile(b) then break end
> if found(b) then row,col = k,n; break 2; end
> end
> end
>
This has been discussed quite often before.
http://lua-users.org/cgi-bin/namazu.cgi?query=break+n&sort=score&idxname=lua-l&max=20
We also now have goto that gives this functionality.
Cheers,
Josh.