<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PaperKit",
  "identifier" : "/documentation/PaperKit/MarkupOrderedSet/insert(_:at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "PaperKit"
    ],
    "preciseIdentifier" : "s:8PaperKit16MarkupOrderedSetV6insert_2atSb8inserted_Si5indextAA0C0_p_SitF"
  },
  "title" : "insert(_:at:)"
}
-->

# insert(_:at:)

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

```
@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

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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)