ScopeExtension<T> extension
Scope functions for non-nullable values
- on
-
- T
Methods
-
also(
void block(T it)) → T -
Available on T, provided by the ScopeExtension extension
Executes block with value as parameter and returns the original value Usage: user.also((it) => print(it.name)) -
apply(
void block(T self)) → T -
Available on T, provided by the ScopeExtension extension
Executes block with value as 'this' context and returns the original value Usage: StringBuilder().apply((self) => self..write('Hello')..write('World')) -
run<
R> (R block(T self)) → R -
Available on T, provided by the ScopeExtension extension
Executes block with value as 'this' context and returns result Usage: user.run((self) => self.name.toUpperCase()) -
takeIf(
bool predicate(T it)) → T? -
Available on T, provided by the ScopeExtension extension
Returns value if it satisfies the predicate, otherwise null Usage: number.takeIf((it) => it > 0)