TakeExtension<T extends Object> extension

Extension for conditionally filtering values.

Provides methods to return the value (as-is) or null based on conditions, useful for filtering in chains or implementing optional transformations.

on
  • T

Methods

takeIf(bool condition) → T?

Available on T, provided by the TakeExtension extension

Returns this value if condition is true, otherwise null.
takeIfLazy(bool predicate(T value)) → T?

Available on T, provided by the TakeExtension extension

Returns this value if predicate returns true for it, otherwise null.
takeUnless(bool condition) → T?

Available on T, provided by the TakeExtension extension

Returns this value if condition is false, otherwise null.
takeUnlessLazy(bool predicate(T value)) → T?

Available on T, provided by the TakeExtension extension

Returns this value if predicate returns false for it, otherwise null.