Ashwini Khare Ashwini Khare - 2 months ago 9x
Scala Question

scala tuple to String

Suppose I have a list of tuples

('a', 1), ('b', 2)...

How would one get about converting it to a String in the format

a 1
b 2

I tried using'\t'))
However I'm getting an error since essentially I'm applying the operation to a tuple instead of a list. Using
didn't help either


For Tuple2 you can use:

val list = List(("1", 4), ("dfg", 67)) { case (str, int) => s"$str $int"}

For any tuples try this code:

val list = List[Product](("dfsgd", 234), ("345345", 345, 456456)) { tuple =>