Skip to content

Commit

Permalink
Remove text.characterAt(…) in favor of .get(…)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasWanke committed Dec 21, 2024
1 parent dbd90d1 commit 96672af
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions packages_v5/example.candy
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@ fun get(self: Text, index: Int) Maybe[Text] {
fun getRange(self: Text, startInclusive: Int, endExclusive: Int) Text {
self.builtinTextGetRange(startInclusive, endExclusive)
}
fun characterAt(self: Text, index: Int) Maybe[Text] {
switch index.isInRange(0, self.length()) {
false => none[Text](),
true => some(self.getRange(index, index.add(1))),
}
}
fun characters(self: Text) List[Text] {
listGenerate(self.length(), (i: Int) { self.get(i).unwrap() })
}
Expand Down Expand Up @@ -305,7 +299,7 @@ fun splitIf(self: Text, predicate: (Text) Bool) List[Text] {
self.splitIfHelper(predicate, 0, 0 listOf[Text]())
}
fun splitIfHelper(self: Text, predicate: (Text) Bool, currentStartOffset: Int, offset: Int, result: List[Text]) List[Text] {
switch self.characterAt(offset) {
switch self.get(offset) {
none => result.append(self.getRange(currentStartOffset, offset)),
some(char) => switch predicate(char) {
true => {
Expand Down

0 comments on commit 96672af

Please sign in to comment.