setSlot<T> method

void setSlot<T>(
  1. int index,
  2. T value
)

Stores the T value in slot index.

Implementation

void setSlot<T>(int index, T value) {
  if (T == double) {
    _bindings.wrenSetSlotDouble(_ptrVm, index, value as double);
  } else if (T == bool) {
    _bindings.wrenSetSlotBool(_ptrVm, index, value as bool);
  } else if (T == String) {
    _bindings.wrenSetSlotBytes(
        _ptrVm, index, (value as String).toNativeUtf8().cast(), value.length);
  } else {
    throw ArgumentError('Invalid type for setSlot');
  }
}