LetExtension<T> extension
Scope functions for null-safe operations
- on
-
- T?
Methods
-
also(
void block(T it)) → T? -
Available on T?, provided by the LetExtension extension
Executes block if value is not null, returns the original value Usage: user?.also((it) => print(it.name)) -
let<
R> (R block(T it)) → R? -
Available on T?, provided by the LetExtension extension
Executes block if value is not null and returns the result Usage: user?.let((it) => it.name) ?? 'Guest' -
takeIf(
bool predicate(T it)) → T? -
Available on T?, provided by the LetExtension extension
Returns value if it satisfies the predicate, otherwise null Usage: number.takeIf((it) => it > 0)