Last updated:
0 purchases
func type result
Features #
Simple functional result-type for alternative exception-handling.
Example #
final rand = Random();
T mightFail<T>(T value) {
if (rand.nextBool()) {
return value;
} else {
throw Exception("Woopsi!");
}
}
main() {
result(() => mightFail("Some value"))
.map((value) => value + "success")
.flatMap((value) => result(() => value.toInt()))
.whenErr((ex) => println(ex));
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.