Skip to content

Commit

Permalink
(yegor256#1462) Use text.Mapped
Browse files Browse the repository at this point in the history
  • Loading branch information
andreoss committed Oct 16, 2020
1 parent 3b6ddce commit a0e1eb9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/cactoos/text/Sub.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,19 @@ public Sub(final Text text, final Scalar<Integer> strt,
public Sub(final Text text, final Unchecked<Integer> start,
final Unchecked<Integer> end) {
super(
new TextOf(
() -> {
new Mapped(
origin -> {
int begin = start.value();
if (begin < 0) {
begin = 0;
}
int finish = end.value();
final String origin = text.asString();
if (origin.length() < finish) {
finish = origin.length();
}
return origin.substring(begin, finish);
}
},
text
)
);
}
Expand Down

0 comments on commit a0e1eb9

Please sign in to comment.