Skip to content

Instantly share code, notes, and snippets.

@samuelchanx
Created January 1, 2022 08:34
Show Gist options
  • Select an option

  • Save samuelchanx/1ba7f13c1ba257a917180df4d4eb891c to your computer and use it in GitHub Desktop.

Select an option

Save samuelchanx/1ba7f13c1ba257a917180df4d4eb891c to your computer and use it in GitHub Desktop.
Missed dart extensions like in kotlin
ReturnType run<ReturnType>(ReturnType Function() operation) {
return operation();
}
extension ScopeFunctionsForObject<T extends Object> on T {
ReturnType let<ReturnType>(ReturnType Function(T item) operationFor) {
return operationFor(this);
}
T also(void Function(T item) operationFor) {
operationFor(this);
return this;
}
}
// Adapted from: https://github.com/YusukeIwaki/dart-kotlin_flavor#let
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment