foldLeft<C> method
C
foldLeft<C>(
- C initial,
- C rightOperation(
- C acc,
- R element
If this is a Right, applies ifRight
with initial
and Right.value.
Returns initial
otherwise.
Example
final Either<Exception, String> result = Either.right('hoc081098');
final String initial = 'dart_either';
String combine(String acc, String v) => '$acc $v';
result.foldLeft<String>(initial, combine); // Result: 'dart_either hoc081098'
Implementation
C foldLeft<C>(C initial, C Function(C acc, R element) rightOperation) =>
_foldInternal(
ifLeft: _const(initial),
ifRight: (r) => rightOperation(initial, r),
);