Removal of StringBuffer clear reduces the usage using final on a StringBuffer . #8615
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
library-core
Noticed with M3 deprecation of clear method it is no longer possible to use one StringBuffer for building up a string. For example:
class A {
final StringBuffer buff = new StringBuffer();
String emitToDebug() => buff.toString();
void reset() { buff.clear; }
}
must now be:
class A {
StringBuffer buff = new StringBuffer();
String emitToDebug() => buff.toString();
void reset() { buff = new StringBuffer(); }
}
Unfortunate, that I can't use final and must allocate the extra object (StringBuffer) to empty my StringBuffer.
I vote to bring back clear().
The text was updated successfully, but these errors were encountered: