---
title: "insert(_:at:)"
framework: paperkit
role: symbol
role_heading: Instance Method
path: "paperkit/markuporderedset/insert(_:at:)"
---

# insert(_:at:)

Inserts a new member at the specified index, if the set doesn’t already contain it.

## Declaration

```swift
@discardableResult mutating func insert(_ item: MarkupOrderedSet.Element, at index: Int) -> (inserted: Bool, index: Int)
```

## Parameters

- `item`: The element to insert.
- `index`: The index to insert at.

## Return Value

Return Value A pair (inserted, index), where inserted is a Boolean value indicating whether the operation added a new element, and index is the index of item in the resulting set. If inserted is false, then the returned index may be different from the index requested.

## See Also

### Adding elements

- [append(_:)](paperkit/markuporderedset/append(_:).md)
- [append(contentsOf:)](paperkit/markuporderedset/append(contentsof:).md)
- [updateOrAppend(_:)](paperkit/markuporderedset/updateorappend(_:).md)
