Scala: join an iterable of strings

The Solution to Scala: join an iterable of strings is


How about mkString ?

theStrings.mkString(",")

A variant exists in which you can specify a prefix and suffix too.

See here for an implementation using foldLeft, which is much more verbose, but perhaps worth looking at for education's sake.

~ Answered on 2012-11-23 12:49:32


Most Viewed Questions: