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

# updateOrAppend(_:)

Adds the given element to the set unconditionally, either appending it to the set, or replacing an existing value if one with the same id is present.

## Declaration

```swift
@discardableResult mutating func updateOrAppend(_ item: MarkupOrderedSet.Element) -> MarkupOrderedSet.Element?
```

## Parameters

- `item`: The value to append or replace.

## Return Value

Return Value The element this operation replaced, or nil if the operation appended the value to the end of the collection.

## See Also

### Adding elements

- [append(_:)](paperkit/markuporderedset/append(_:).md)
- [append(contentsOf:)](paperkit/markuporderedset/append(contentsof:).md)
- [insert(_:at:)](paperkit/markuporderedset/insert(_:at:).md)
