pub fn remove(state: &mut LuaState) -> Result<usize, LuaError>Expand description
C: tremove(L) — implements table.remove(t [, pos]).
static int tremove (lua_State *L) {
lua_Integer size = aux_getn(L, 1, TAB_RW);
lua_Integer pos = luaL_optinteger(L, 2, size);
if (pos != size)
luaL_argcheck(L, (lua_Unsigned)pos - 1u <= (lua_Unsigned)size, 2,
"position out of bounds");
lua_geti(L, 1, pos);
for ( ; pos < size; pos++) {
lua_geti(L, 1, pos + 1);
lua_seti(L, 1, pos);
}
lua_pushnil(L);
lua_seti(L, 1, pos);
return 1;
}