I have an Array of Tuple2 that contains a String and a map, and I'd like to print for each tuple2 as many rows as the number of keys of the map. This is what I wrote:
val a = Array(
("foo", HashMap(1->"f1", 2->"f2")),
("bar", HashMap(1->"b1", 2->"b2"))
)
for (sourceNode <- a) {
for (destNode <- sourceNode._2) {
println("value [" + sourceNode._1 + "] for [" + destNode._1 + "] is '" + destNode._2 + "'")
}
}
and here is the result:
value [foo] for [1] is 'f1'
value [foo] for [2] is 'f2'
value [bar] for [1] is 'b1'
value [bar] for [2] is 'b2'
The result is correct, but is there a more concise (and functional) way to obtain this result?
Thanks, Andrea