removeLast method
Removes the last n
characters from the String
.
Example
String foo = 'esentis';
String newFoo = foo.removeLast(3); // 'esen';
Implementation
String removeLast(int n) {
if (this.isBlank || n <= 0) {
return this;
}
if (n >= this.length) {
return '';
}
return this.substring(0, this.length - n);
}