lua-users home
lua-l archive

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


On Wed, May 19, 2010 at 9:27 PM, Mark Feldman
<mfeldman@infinite-interactive.com> wrote:
> It's trivial to add yourself, as demonstated in PIL:
>
>     function iter (a, i)
>       i = i + 1
>       local v = a[i]
>       if v then
>         return i, v
>       end
>     end

Don't forget that "if v then" will evaluate both "nil" and "false" as
false. A more coherent condition is "if v ~= nil then"

--rb