I often work with lists, sections, and iterators of tuples and would like to do something like the following,
val arrayOfTuples = List((1, "Two"), (3, "Four")) arrayOfTuples.map { (e1: Int, e2: String) => e1.toString + e2 }
However, the compiler never agrees with this syntax. Instead, I finish writing,
arrayOfTuples.map { t => val e1 = t._1 val e2 = t._2 e1.toString + e2 }
This is just stupid. How can I get around this?
iterator scala tuples iterable-unpacking map
duckworthd Aug 01 '11 at 10:22 2011-08-01 22:22
source share