class QuotedList(list):
def __init__(self, x, /, d='\t', q='\''):
super().__init__()
self.d, self.q = d, q
for x in x: self.append(x)
def append(self, x):
if any(c in ws for c in x):
q = self.q
x = q + x + q
return super().append(x)
def to_string(self):
return self.d.join(self)
x = QuotedList(a, d, q)
s = x.to_string()
class QuotedList extends ArrayList<String> {
String d, q;
QuotedList(String d, String q) {
this.d = d;
this.q = q;
}
public boolean add(String s) {
if (s.contains(" ")) s = q + s + q;
return super.add(s);
}
public String toString() {
return join(d, this);
}
}
QuotedList x = new QuotedList(d, q) {{
for (var x : a) add(x);
}};
String s = x.toString();