---
title: "init(_:)"
framework: swift
role: symbol
role_heading: Initializer
path: "swift/collectiondifference/init(_:)"
---

# init(_:)

Creates a new collection difference from a collection of changes.

## Declaration

```swift
init?<Changes>(_ changes: Changes) where Changes : Collection, Changes.Element == CollectionDifference<ChangeElement>.Change
```

## Parameters

- `changes`: A collection of changes that represent a transition between two states.

## Discussion

Discussion To find the difference between two collections, use the difference(from:) method declared on the BidirectionalCollection protocol. The collection of changes passed as changes must meet these requirements: All insertion offsets are unique All removal offsets are unique All associations between insertions and removals are symmetric note: O(n * log(n)), where n is the length of the parameter.
