Tuple Unpacking in Map Operations

后端 未结 6 1544
慢半拍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:17

    I like the tupled function; it's both convenient and not least, type safe:

    import Function.tupled
    arrayOfTuples map tupled { (e1, e2) => e1.toString + e2 }
    

提交回复
热议问题