val inception = ("Scala", "Nesoy", ("Scala", "Nesoy"))inception._3._1
Tuple을 활용한 Pattern Matching
val (name, quantity) = ingredientprintln(name) // Sugarprintln(quantity) // 25
for-each Example
val planets = List(("Mercury", 57.9), ("Venus", 108.2), ("Earth", 149.6), ("Mars", 227.9), ("Jupiter", 778.3))planets.foreach{ // Java에서는 힘든 표현이다. case ("Earth", distance) => println(s"Our planet is $distance million kilometers from the sun") case _ =>}
for-loop Example
val numPairs = List((2, 5), (3, -7), (20, 56))for ((a, b) <- numPairs) { println(a * b)}