This chapter is from the book
4.9 Zipping
One reason for using tuples is to bundle together values so that they can be processed together. This is commonly done with thezipmethod. For example, the code
val符号=数组 ("<", "-", ">") val数=一个rray(2, 10, 2) val pairs = symbols.zip(counts)
yields an array of pairs
Array(("<", 2), ("-", 10), (">", 2))
The pairs can then be processed together:
for (s, n) <- pairs do print(s * n) //Prints <<---------->>