Zipping

Scala Comments

In this blog post, you’ll learn about

  1. How to merge the values of 2 collections (list, array, buffer etc).

Zip

If you want to merge the values of 2 collections so that they can be processed together, here’s how you might do it in Java -

// Now, if I know that the keys and values are of the same length and are in order, I might want to process them together.

However, the following operation can be easily done in Scala using the zip operation.

ZipWithIndex

An extension of the zip operation is the zipWithIndex. The function of this is self-explanatory.

Kaushik Rangadurai

Code. Learn. Explore

Share this post

Comments