0

I have the following list:

val aList: Seq[String] = List("A", "B", "C", "D", "E")

I want to return the string: "A-B-C-D-E". The following code does it:

aList.map(_ + "-").fold("")(_ + _).dropRight(1)

But as you can see, with the map and the fold operations, I need to drop the last "-" character at the end. I'm wondering if there is a way to do it on a way that is simpler and more direct (without using the dropRight function).

Any help would be appreciated.

0 Answers0