removeRepeatedChars method

  1. @useResult
String removeRepeatedChars()

Implementation

@useResult
String removeRepeatedChars() {
  if (length <= 1) return this;
  final StringBuffer sb = StringBuffer(this[0]);
  for (int i = 1; i < length; i++) {
    if (this[i] != this[i - 1]) sb.write(this[i]);
  }
  return sb.toString();
}