Deconstruction
Extract from data.
What Is Deconstruction?
Deconstruction (also called destructuring) means extracting the parts of a data structure directly in a pattern.
Instead of calling accessor methods, you describe the shape and name the pieces you want.
Deconstructing a Tuple
A tuple groups several values. You can pull them apart in a single binding by writing names in parentheses.
object Main {
def main(args: Array[String]): Unit = {
val pair = ("Ada", 1815)
val (name, year) = pair
println(s"$name was born in $year")
}
}