Home »
Code Examples »
Scala Code Examples
Scala - How to use zip method? Code Example
The code for How to use zip method?
object Demo {
def main(args: Array[String]) = {
val IDs = List(101, 102, 103, 104)
val Names = List("Alvin", "Alex", "Mark", "Den")
//apply operation to create a zip of list
val result = IDs zip Names
//print list
println(result)
}
}
/*
Output:
List((101,Alvin), (102,Alex), (103,Mark), (104,Den))
*/
Code by IncludeHelp,
on August 13, 2022 20:38