Skip to content

Commit

Permalink
Fixed small bug in index that didn't return -1 when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
joelgallant committed Jul 1, 2013
1 parent be35ff5 commit 37e4ff9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/edu/first/util/Strings.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public static boolean isEmpty(String string) {
public static int indexThatIsnt(String string, String s, String i) {
int index;
int spare = 0;
while ((index = string.indexOf(s)) > 0 && index == string.indexOf(i)) {
while ((index = string.indexOf(s)) >= 0 && index == string.indexOf(i)) {
string = string.substring(index + i.length());
spare += index + i.length();
}
return index + spare;
return index < 0 ? -1 : index + spare;
}

/**
Expand Down

0 comments on commit 37e4ff9

Please sign in to comment.