lua-users home
lua-l archive

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


On 1 August 2014 11:47, Patrick Donnelly <batrick@batbytes.com> wrote:
local function append (t, v)
  return table.insert(t, #t, v)
end
In this case, why even use table.insert, just have `t[#t+1] = v`

You could also just use

    local function append(t,v)
        return table.insert(t, v)
    end

==> now you'll never accidently pass 3 arguments to insert.

But now you've lost the speed advantage:
I recall table.insert was a tiny bit faster than doing it in lua, according to some benchmarks waqas did.