tableRemove method

LuaObject? tableRemove(
  1. int index
)

Convenience method to implement std table methods.

Returns null if there was a problem. Otherwise, returns the removed lua object.

Implementation

LuaObject? tableRemove(int index) {
  uses++;
  if (isTable) {
    LuaObject? out;
    deref()._fields?.removeWhere((key, value) {
      if (key == index.toString()) {
        out = value;
        return true;
      }

      return false;
    });
    return out;
  }

  return null;
}