Skip to content

Commit

Permalink
Create StringSlice::contains(char)
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavo committed Nov 3, 2023
1 parent be648c3 commit e322f9d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kala-base/src/main/java/kala/text/StringSlice.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ public int indexOf(int ch, int fromIndex) {
return idx >= offset && idx < offset + length ? idx - offset : -1;
}

public boolean contains(char ch) {
return indexOf(ch) >= 0;
}

public boolean contains(String other) {
int idx = value.indexOf(other, offset);
return idx >= 0 && idx <= offset + length - other.length();
Expand Down

0 comments on commit e322f9d

Please sign in to comment.