# unzip

## definition

The unzip method will unzip and un-merge a collection consisting of element pairs or Tuple2 into two separate collections.

其实也就是zip的逆操作

```scala
def unzip[A1, A2](implicit asPair: (A) ⇒ (A1, A2)): (CC[A1], CC[A2])
```

## demo

```scala
scala> val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
donuts: Seq[String] = List(Plain Donut, Strawberry Donut, Glazed Donut)

scala> val donutPrices = Seq[Double](1.5, 2.0, 2.5)
donutPrices: Seq[Double] = List(1.5, 2.0, 2.5)

scala> val zippedDonutsAndPrices: Seq[(String, Double)] = donuts zip donutPrices
zippedDonutsAndPrices: Seq[(String, Double)] = List((Plain Donut,1.5), (Strawberry Donut,2.0), (Glazed Donut,2.5))

scala> val unzipped: (Seq[String], Seq[Double]) = zippedDonutsAndPrices.unzip
unzipped: (Seq[String], Seq[Double]) = (List(Plain Donut, Strawberry Donut, Glazed Donut),List(1.5, 2.0, 2.5))
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.selinux.tech/scala/function-operation/u/unzip.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
