GenericScrewdriver<T extends Object> extension

provides scope functions as extensions on T

on
  • T

Methods

apply(void block(T obj)) → T
Calls the specified function block with this value as its argument and returns this value.
run<R>(R block(T obj)) → R
Calls the specified function block with this value as its argument and returns this value.
takeIf(bool predicate(T obj)) → T?
Returns this if it satisfies the given predicate or null, if it doesn't.
takeUnless(bool predicate(T obj)) → T?
Returns this if it doesn't satisfy the given predicate or null, if it doesn't.
tryCast<R>() → R?
A safe cast operation that returns null if the cast is not possible. Otherwise, returns the casted value.