Method: Lua::Table#__set

Defined in:
ext/rlua.c

#__set(key, value) ⇒ Object

Sets value associated with key to value in Lua table without invoking any Lua metamethod (similar to rawset Lua function).



395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'ext/rlua.c', line 395

static VALUE rbLuaTable_rawset(VALUE self, VALUE index, VALUE value)
{
  lua_State* state;
  Data_Get_Struct(rb_iv_get(self, "@state"), lua_State, state);

  rlua_push_var(state, self);                      // stack: |this|...
  rlua_push_var(state, index);                     //        |indx|this|...
  rlua_push_var(state, value);                     //        |valu|indx|this|...
  lua_rawset(state, -3);                           //        |this|...
  lua_pop(state, 1);                               //        ...

  return value;
}