Tuple Unpacking in Map Operations

后端 未结 6 1546
慢半拍i
慢半拍i 2020-12-07 15:46

I frequently find myself working with Lists, Seqs, and Iterators of Tuples and would like to do something like the following,

val arrayOfTuples = List((1, \"         


        
6条回答
  •  春和景丽
    2020-12-07 16:13

    I think for comprehension is the most natural solution here:

    for ((e1, e2) <- arrayOfTuples) yield {
      e1.toString + e2
    }
    

提交回复
热议问题