We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2be5f1c commit 0bbb9a7Copy full SHA for 0bbb9a7
1 file changed
packages/fpdart/lib/src/extension/iterable_extension.dart
@@ -429,15 +429,12 @@ extension FpdartOnIterable<T> on Iterable<T> {
429
Option<T> singleWhereOption(bool Function(T element) test) {
430
T? result;
431
var found = false;
432
+
433
for (final element in this) {
434
if (test(element)) {
- if (!found) {
435
- result = element;
436
- found = true;
437
- } else {
438
- result = null;
439
- break;
440
- }
+ if (found) return const Option.none();
+ result = element;
+ found = true;
441
}
442
443
0 commit comments