user3663882 user3663882 - 1 year ago 73
Scala Question

Transform map to key=value pairs

I have a

map: Map[AnyRef, AnyRef]
. What is the best way to map it in the following string

"key1=value1 key2=value2 ..."

In Java that's easy. I would just use it

.map(e -> e.getKey().toString() + "=" + e.getValue().toString())
.collect(joining(" "))

But how to do that in Scala?

Answer Source case (a, b) -> a.toString + "=" + b.toString).mkString(" ")