From 76d28266bebfb3acb237a475d3c1ef14091bc7c3 Mon Sep 17 00:00:00 2001 From: mcmah309 Date: Mon, 9 Dec 2024 17:26:26 +0000 Subject: [PATCH] doc: Update --- README.md | 2 +- test/iter/iter_test.dart | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ab86e8b..8c1afa0 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ void main() { break; case ["!", _]: answer.push(index); - case [_, "!"] when iter.peek().isNone(): + case [_, "!"] when iter.peek() == null: // or `iter.peekOpt().isNone()` answer.push(index + 1); } } diff --git a/test/iter/iter_test.dart b/test/iter/iter_test.dart index 6ddf1b5..3f5c017 100644 --- a/test/iter/iter_test.dart +++ b/test/iter/iter_test.dart @@ -1160,19 +1160,20 @@ main() { test("Use case example 6", () { /// Get the index of every "!" in a string not followed by a "?" - List answer = []; - String string = "kl!sd!?!"; + final string = "kl!sd!?!"; + Vec answer = []; Peekable<(int, Arr)> iter = string.chars().mapWindows(2, identity).enumerate().peekable(); + while (iter.moveNext()) { final (index, window) = iter.current; switch (window) { case ["!", "?"]: break; case ["!", _]: - answer.add(index); - case [_, "!"] when iter.peekOpt().isNone(): - answer.add(index + 1); + answer.push(index); + case [_, "!"] when iter.peek() == null: + answer.push(index + 1); } } expect(answer, [2, 7]);