maybe_just_nothing 0.1.9 copy "maybe_just_nothing: ^0.1.9" to clipboard
maybe_just_nothing: ^0.1.9 copied to clipboard

outdated

Yet another variation of the good old Maybe monad with eager execution written in Dart. Or maybe it's just nothing.

example/example.dart

import 'package:maybe_just_nothing/maybe_just_nothing.dart';

Maybe<int> addTwoIntegers(dynamic a, dynamic b) =>
    Maybe(a).cast<int>().merge(Maybe(b).cast<int>(), (a, b) => a + b);

void main() {
  // Prints 42
  addTwoIntegers(40, 2).ifPresent(print);

  // Does nothing since one of the values is null.
  addTwoIntegers(40, null).ifPresent(print);

  // Does nothing since one of the values is not an integer.
  addTwoIntegers('Oops', 2).ifPresent(print);
}
7
likes
0
pub points
65%
popularity

Publisher

verified publisherkarapetov.com

Yet another variation of the good old Maybe monad with eager execution written in Dart. Or maybe it's just nothing.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on maybe_just_nothing