Say I have list of strings in Ceylon. (It does not have to be a List<String>
; it could be an iterable, sequence, array, etc.) What is the best way to concatenate all these strings into one string?
The most efficient solution is to use the static method String.sum()
, since that is optimized for a stream of String
s (and uses a StringBuilder
) under the covers.
value concat = String.sum(strings);
The other solutions proposed here, while correct, all use generic functions based on Summable
, which in principle are slightly slower.