我有两个问题:
首先
我什么时候应该让应用程序崩溃?
第二:
此代码来自 resoCoder。我不明白!!!!!!!!!!!!todos
如果不正确,他怎么能让应用程序崩溃?!
T getOrCrash() {
// id = identity - same as writing (right) => right
return value.fold((f) => throw UnexpectedValueError(f), id);
}
Option<ValueFailure<dynamic>> get failureOption {
return body.failureOrUnit
.andThen(color.failureOrUnit)
.andThen(todos.failureOrUnit)
.andThen(
todos
.getOrCrash() // is this crash is okay?!! why to do so???????!
.map((todoItem) => todoItem.failureOption)
.filter((o) => o.isSome())
.getOrElse(0, (_) => none())
.fold(() => right(unit), (f) => left(f)),
)
.fold((f) => some(f), (_) => none());
}