takeIf method

T? takeIf(
  1. bool condition
)

Kotlin-esque "operator" to take this if condition is true, or else return null.

Implementation

T? takeIf(bool condition) => condition ? this : null;