1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
Str joinPlain(Array<Str> src) {
StrBuf out;
out << join(src);
out.toS;
}
Str joinSep(Array<Str> src) {
StrBuf out;
out << join(src, ", ");
out.toS;
}
Str joinTfm(Array<Str> src) {
StrBuf out;
out << join(src, (x) => "test-" + x);
// Two of these have been problematic historically (lambdas generate a null, which the join
// corrects, thus generating multiple instances of the join function.
out << join(src, (x) => "test2-" + x);
out.toS;
}
Str joinTfmSep(Array<Str> src) {
StrBuf out;
out << join(src, ", ", (x) => "test-" + x);
// Two of these have been problematic historically (lambdas generate a null, which the join
// corrects, thus generating multiple instances of the join function.
out << join(src, ", ", (x) => "test2-" + x);
out.toS;
}
|