# \#swap

**URL:** https://forums.swift.org/tag/swap/1003.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [Why is swapAt not using swap?](https://forums.swift.org/t/why-is-swapat-not-using-swap/71854)

<div class="topic-metadata">

**Author:** [@wadetregaskis](https://forums.swift.org/u/wadetregaskis)\
**Replies:** 12\
**Last updated:** [May 31, 2024, 12:33pm UTC](https://forums.swift.org/t/why-is-swapat-not-using-swap/71854 "2024-05-31T12:33:20Z")

</div>

I noticed that swapAt uses the naive approach with a named temporary variable. It doesn't even do a tuple swap ((a, b) = (b, a)). Usually the naive approach is dangerous for performance as it relies on the optimiser re…
