scope_functions library
Scope functions module for Dartlin package.
This module provides scope functions similar to Kotlin:
- let: executes a block and returns the result
- also: executes a block and returns the original object
- apply: executes a block on the object and returns the object
Example usage:
import 'package:darlin/scope_functions.dart';
void main() {
final result = 'hello'.let((it) => it.toUpperCase());
'hello'.also((it) => print('Processing: $it'));
final map = <String, dynamic>{}.apply((it) {
it['name'] = 'John';
it['age'] = 30;
});
}
Extensions
- ScopeFunctions on T?
- Extensions on any nullable object to provide Kotlin-like scope functions.