tryAs<T> method

  1. @useResult
T? tryAs<T>()

Safely casts the value to T if it is T, otherwise returns null.

Implementation

@useResult
T? tryAs<T>() => this is T ? this as T : null;