Skip to content

Commit 9322334

Browse files
committed
Add starts_with to Slice.
1 parent 273b6c0 commit 9322334

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

python/selfie-lib/selfie_lib/Slice.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,8 @@ def count(self, char: str) -> int:
8989

9090
def baseLineAtOffset(self, index: int) -> int:
9191
return 1 + Slice(self.base, 0, index).count("\n")
92+
93+
def starts_with(self, prefix: str) -> bool:
94+
if len(prefix) > len(self):
95+
return False
96+
return all(self[i] == prefix[i] for i in range(len(prefix)))

0 commit comments

Comments
 (0)