---
title: "merging(_:mergePolicy:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/attributecontainer/merging(_:mergepolicy:)"
---

# merging(_:mergePolicy:)

Returns an attribute container by merging the container’s attributes with those in another attribute container.

## Declaration

```swift
func merging(_ other: AttributeContainer, mergePolicy: AttributedString.AttributeMergePolicy = .keepNew) -> AttributeContainer
```

## Parameters

- `other`: The attribute container with the attributes to merge.
- `mergePolicy`: A policy to use when resolving conflicts between this string’s attributes and those in other.

## Return Value

Return Value An attribute container created by merging the source container’s attributes with those in another attribute container.

## See Also

### Modifying Attributes

- [merge(_:mergePolicy:)](foundation/attributecontainer/merge(_:mergepolicy:).md)
- [AttributedString.AttributeMergePolicy](foundation/attributedstring/attributemergepolicy.md)
