SplitScript reference / T! / discardError

T!.discardError

Method

T!.discardError() -> T?

Converts a fallible value into an optional value.

A success becomes the present optional value. An error becomes None, discarding its diagnostic text. This is useful for state fields that are deliberately unavailable on some ticks; required fields should keep their T! so a failed read retains the last accepted field value.

Effects: pure

Runtime behavior: available everywhere; synchronous

Examples

Make one process read optional

let health: i32? = process.read<i32>(0x1000).discardError()