valueAs<T> method
T?
valueAs<T>()
Inspects this.value. If the type
is LuaObject, inspects its this.value.
If the underlying value type is T, then
it is returned. If no underlying value type
matches T, the null is returned.
For tables, see fieldValueAs.
Implementation
T? valueAs<T>() {
uses++;
_onRead?.call('self');
return switch (value) {
final LuaObject obj => switch (obj.value) {
final T v => v,
_ => null,
},
final T v => v,
_ => null,
};
}