TakeIfExtension<T> extension

Extension on T to add takeIf and takeUnless methods.

on
  • T

Methods

takeIf(bool predicate(T)) → T?

Available on T, provided by the TakeIfExtension extension

Evaluates the given predicate function on the value of type T and returns the value if the predicate is true, otherwise returns null.
takeUnless(bool predicate(T)) → T?

Available on T, provided by the TakeIfExtension extension

Evaluates the given predicate function on the value of type T and returns the value if the predicate is false, otherwise returns null.